prop

.prop() vs .attr()

拈花ヽ惹草 提交于 2021-02-05 12:32:47
问题 So jQuery 1.6 has the new function prop(). $(selector).click(function(){ //instead of: this.getAttribute('style'); //do i use: $(this).prop('style'); //or: $(this).attr('style'); }) or in this case do they do the same thing? And if I do have to switch to using prop() , all the old attr() calls will break if i switch to 1.6? UPDATE selector = '#id' $(selector).click(function() { //instead of: var getAtt = this.getAttribute('style'); //do i use: var thisProp = $(this).prop('style'); //or: var

React replace componentWillReceiveProps

社会主义新天地 提交于 2020-08-10 13:08:47
问题 Having the following method in my child component which updates state on prop changes which works fine componentWillReceiveProps(nextProps) { // update original states this.setState({ fields: nextProps.fields, containerClass: nextProps.containerClass }); } I'm getting Warning: Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code. and I try to update but till now without any success static getDerivedStateFromProps(nextProps, prevState) {

jquery on certain option select on first select list, enable second select list

半城伤御伤魂 提交于 2020-01-17 04:06:05
问题 I'm trying to solve a situation where you have two select lists and on first and second option from first list, second list gets enabled. Ok, I have #decide and #day select lists, #day is disabled by default. If User would select option yes: or maybe: from #decide list, #day list would get enabled with $('#day').prop('disabled', false); else or if the any other option is selected it would give back that disabled property to #day: $('#day').prop('disabled', true); currently I have only html:

Vuejs Mutating Object passed as a prop

久未见 提交于 2020-01-16 08:55:10
问题 If I'm passing (a reference to) an Object as a prop is it OK to mutate values in the prop? I'm developing a web app which will require a lot of values to be passed to a component, and I'm trying to find the best way of passing the values to the component and back to the parent. From everything I've read mutating a prop is the wrong way to do things, because next time the component is updated the values are passed back to the child component overwriting the mutations. But only the reference to

When is it preferable to use `attr()` instead of `.prop()`? [duplicate]

北战南征 提交于 2020-01-13 07:29:10
问题 This question already has answers here : .prop() vs .attr() (17 answers) Closed 6 years ago . ( Note : While it may be tempting to say this is a duplicate of .prop() vs .attr(), I do not believe it is. That post does a fantastic job explaining the difference between .prop() and .attr() but does not state definitively when one is preferable over the other, which is what this question aims to do.) Despite having read a number of questions/answers on StackOverflow regarding the differences

jQuery attr vs. prop, there are a list of props? [closed]

孤街浪徒 提交于 2020-01-11 09:20:36
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . This is not a duplicate question, I need only to decide if the better/fast/correct is to use attr or to use prop . The simplest and reliable way is checking into a list. A " list of element-name where the better

Count the current number of inputs with a specific property after a function has run which has changed these properties

 ̄綄美尐妖づ 提交于 2020-01-03 04:48:05
问题 Related to this question: Using jQuery, keep a form's submit button disabled until all of the required textbox, radio, checkbox elements have a value (or are checked) I was very kindly helped to put together this function $('input[type=submit]').prop('disabled', true).addClass('disabled'); var required = $('[required]'); required.bind('change keyup', function() { var flag = 0; required.each(function() { if ($(this).not(':checkbox, :radio').val() || $(this).filter(':checked').val()) { flag++;

Disable opposite input if I type into another of a pair

…衆ロ難τιáo~ 提交于 2019-12-25 01:49:40
问题 How do I disable one input field if I type into another out of a pair and then if I removed the input by hitting backspace for example so there is nothing in the input field reenable the second input field and vice versa. Code I have so far is below but is not working. JavaScript: //disable the opposite input field var ATGvalue = $('input#atgOrderId').val(); var BQvalue = $('input#bqOrderId').val(); if ( ATGvalue.length > 0) { $('input#bqOrderId').prop("disabled", true); } else { $('input

Should href be set with prop() or attr()? [duplicate]

为君一笑 提交于 2019-12-18 18:36:43
问题 This question already has answers here : How to change the href for a hyperlink using jQuery (11 answers) .prop() vs .attr() (17 answers) Closed 6 years ago . If I want to change the href of a link dynamically, should I do so using prop() or attr() ? 回答1: You would use .attr() , as .prop() is more commonly used for boolean properties such as checked , selected , etc - though it is certainly possible with .prop it's arguably less clear as per your intent Though I do believe that ultimately

changing the img src with jquery

孤人 提交于 2019-12-18 03:57:15
问题 The html structure I have is something like: <ul id="something"> <li> <a href=""> <img src="http://domain.com/directory/file1-128x79.jpg"> </a> </li> <li> <a href=""> <img src="http://domain.com/directory/file2-128x79.jpg"> </a> </li> <li> <a href=""> <img src="http://domain.com/directory/file3-128x79.jpg"> </a> </li> </ul> I'm trying to change the filename from file#-128x79.jpg to file#-896x277.jpg . I don't know how to take the dynamically generated filename and search and replace for the