jQuery Attributes - Examples



Learn how to play with attributes in jQuery. Here are most commonly used examples −

  1. How to get value of attribute custom for the first element matching with ID myID?

  2. How to set the alt attribute of all the images to a new value "Sample Image"?

  3. How to set the value of all <input> elements to the empty string, as well as sets The jQuery Example to the string Please enter a value?

  4. How to select all links with an href attribute starting with http:// and set its target attribute to _blank?

  5. How to remove target attribute of all the links?

  6. How to modify the disabled attribute to the value "disabled" while clicking Submit button?

  7. How to check if last <p> tag has associated class selected?

  8. How to get string that contains the combined text contents of all matched <p> elements?

  9. How to set "Hello World" as text content of the matching <p> elements?

  10. How to get the HTML content of the all matching paragraphs?

  11. How to set the HTML content of all matching <div> to Hello World?

  12. How to get the first value from a checked checkbox?

  13. How to get the first value from a set of radio buttons?

  14. How to set the value attribute of every matched element <button>?

  15. How to check check all the radio or check box button whose value is "on"?

  16. How to select Orange option in a dropdown box with options Orange, Mango and Banana?

  17. How to select Orange and Mango options in a dropdown box with options Orange, Mango and Banana?

Advertisements