You can add attributes using attr
like so:
$('#someid').attr('name', 'value');
However, for DOM properties like checked
, disabled
and readonly
, the proper way to do this (as of JQuery 1.6) is to use prop
.
$('#someid').prop('disabled', true);
More Related Contents:
- jquery html() strips out script tags
- Can I open a dropdownlist using jQuery
- iframe to Only Show a Certain Part of the Page
- How to force a html5 form validation without submitting it via jQuery
- Play/pause HTML 5 video using JQuery
- How to set data attributes in HTML elements
- Find text string in jQuery and make it bold
- jquery – Click event not working for dynamically created button [duplicate]
- Ajax in Jquery does not work from local file
- Hide Twitter Bootstrap nav collapse on click
- Adding data attribute to DOM
- How can I show and hide elements based on selected option with jQuery?
- jQuery Scroll to Div
- expand/collapse table rows with JQuery
- How to stay on current window when the link opens in new tab?
- How can I display a tooltip on an HTML “option” tag?
- Bootstrap throws Uncaught Error: Bootstrap’s JavaScript requires jQuery [closed]
- jQuery get the id/value of element after click function
- Removing file from multiple files uploader on button click when using HTML5 file input
- Creating a hole in a element
- CORS request – why are the cookies not sent?
- How can I change HTML attribute names with jQuery?
- Calculate Position of selected text javascript/JQuery?
- jquery can’t get data attribute value
- Animate counter when in viewport
- How add spaces between Slick carousel item
- Datatables warning(table id = ‘example’): cannot reinitialise data table
- jQuery web page height
- jQuery: find input field closest to button
- How do I select an element with special characters in the ID?