All Questions

1936
votes
16answers
474067 views

.prop() vs .attr()

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...
91
votes
4answers
31154 views

jQuery attr vs prop?

Now this isn't just another What's the difference question, I have done some tests(http://jsfiddle.net/ZC3Lf/) modifying the prop and attr of <form action="/test/"></form>​ with the out...
58
votes
3answers
71660 views

difference between prop() and attr() in jQuery and when to use attr() and prop()

I saw in some places .attr() is used in jQuery.In some places .prop() is used.But i searched in SO and google i am very confused .Please tell me the exact difference between these two and when ...
70
votes
2answers
95868 views

Getting the User Agent with JavaScript

I'd like to get a script that can grab the user's user agent and prop it to an attribute. I'm making a website problems contact form and I usually need to know what browser the user is using. How can...
26
votes
4answers
6878 views

Why jQuery 1.9+ attr() method not deprecated?

Can I, a jQuery1.9+ software developer, "deprecate" the use of the attr() method in my day-by-day work? As showed in many questions, .prop() vs .attr() (main) jQuery attr vs. prop, there are a ...
14
votes
7answers
27015 views

changing the img src with jquery

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...
4
votes
2answers
3524 views

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

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 t...
2
votes
1answers
748 views

Warning: Unknown prop on <> tag. Remove this prop from the element

I'm new to react and i was learning subclasses from one of Lynda examples. I'm creating a new subcomponent class called aptList and using this.props.eachItem.ownerName to iterate through each index fr...
5
votes
1answers
2913 views

jQuery .prop() returns undefined, while .attr() works as expected for data-*

I am simply trying to get a couple of properties from two elements. Getting the property value from the input element works as expected. The problem is with getting the property data-detail property f...
22
votes
1answers
6331 views

Should href be set with prop() or attr()?

If I want to change the href of a link dynamically, should I do so using prop() or attr()?

Previous Next