All Questions

1936
votes
16answers
474068 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...
69
votes
7answers
283646 views

How to change href of <a> tag on button click through javascript

How to change the href attribute value of an <a/> tag through Javascript on button click ? <script type="text/javascript"> function f1() { document.getElementById("abc").href="xyz...
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 ...
141
votes
6answers
131393 views

Toggle input disabled attribute using jQuery

Here is my code: $("#product1 :checkbox").click(function(){ $(this) .closest('tr') // Find the parent row. .find(":input[type='text']") // Find text elements in that row. ...
129
votes
3answers
60181 views

Set attribute without value

How do I set a data attribute without adding a value in jQuery? I want this: <body data-body> I tried: $('body').attr('data-body'); // this is a getter, not working $('body').attr('data-body...
34
votes
8answers
142075 views

jQuery .attr("disabled", "disabled") not working in Chrome

Not sure why this isn't working. When people click the 'edit' button of my application, the disabled textfields become editable: $("#bewerken").click(function(e) { $("input[disabled='disabled...
9
votes
4answers
7148 views

jQuery - How to select value by attribute name starts with

I want to select attribute value by giving attribute name (only starts with) For instance if we have html tag <div class = "slide" data-confirmID = "46" confirmID = "54"/> I want to select t...
23
votes
3answers
24794 views

CSS set background-image by data-image attr

I have sort of elements with this pattern: <div data-image="{imageurl}" ...></div> I want to set this elements background-image to data-image. I test this CSS code: div[data-image] { ...
17
votes
2answers
11457 views

Css Content, Attr and Url in the same sentence

I have used the content attribute for a long time, and today I wanted to try something new. Instead of using JS to display a image tooltip I wanted to know if it was possible to do it dynamically with...

Previous Next