Questions tagged [prop]

The prop() function was added in jQuery 1.6 library. It returns a property for the first element of the matched set.

The .prop() method gets the property value for only the first element in the matched set. It returns undefined for the value of a property that has not been set, or if the matched set has no elements. To get the value for each element individually, use a looping construct such as jQuery's .each() or .map() method.

The difference between attributes and properties can be important in specific situations. Before jQuery 1.6, the .attr() method sometimes took property values into account when retrieving some attributes, which could cause inconsistent behavior. As of jQuery 1.6, the .prop() method provides a way to explicitly retrieve property values, while .attr() retrieves attributes.

293 questions
-1
votes
2 answers

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

(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…
Derek Henderson
  • 8,695
  • 3
  • 34
  • 68
-2
votes
1 answer

.prop() not doing anything to target radio buttons

I'm trying to uncheck a group of 2 radio buttons.
Vereonix
  • 1,103
  • 5
  • 17
  • 46
-2
votes
1 answer

Check if input is checked ONLOAD and ONCHANGE

My javascript skills are subpar so I won't post what I've already tried with jQuery. I can say, however, that I've tried lots of things and nothing worked completely. The scenario is simple: I have several containers. All of them with a checkbox…
ronaldpoi
  • 133
  • 5
-2
votes
2 answers

.prop("checked", false) doesn't work perfectly

In order to uncheck a radio button with Jquery... I use this code : $('input[type=radio][name=belvg_customerattributes_particulier]:checked').prop("checked", false); This code works but visualy I still see the button on checked. I tried this :…
Sébastien
  • 77
  • 1
  • 2
-2
votes
1 answer

Cannot access element created after page load using jQuery

I have a site which has an element with a specific id. I would like to get the href attribute using jQuery. I am trying to do the following: alert($("#id").prop('href')); But it says 'undefined'. I tried setting the timer function as well as using…
-3
votes
3 answers

Undefined when trying to use addClass on $(this) anchor tag

function showImage(imageSrc) { $('a.slideTabLinkBlock').removeClass('active'); alert($(this).attr('class')); $(this).addClass('active'); }
-3
votes
1 answer

jquery prop worked but not now

i wrote a jquery function using prop to uncheck all checkboxes in my page. it was working fine, but today all of sudden, it is not working. below is my code $(function() { $("#ctl00_ContentPlaceHolder1_chkSelectAll").click(function()…
user1447718
  • 619
  • 1
  • 8
  • 20
-4
votes
1 answer

JS doesn't work, syntax error?

why this JS: doesn't work? is there any quotes errors? The script…
strongff
  • 1
  • 2
1 2 3
19
20