| description | Attribute jquery |
|---|---|
| keywords | js, jquery |
| title | Attribute jquery |
| toc_max | 4 |
href, src, id, class, style
$(function() {
var val = $("a").attr("href");
alert(val);
});$(function() {
$("table").removeAttr("border");
$("table").removeAttr("class");
});- retrive html
$(function() {
var val = $("p").html();
alert(val);
});- retrive text
$(function() {
var val = $("p").text();
alert(val);
});- retrive input value
$(function() {
alert($("#name").val());
});append()inserts content at the end of the selected elements.prepend()inserts content at the beginning of the selected elements.after()inserts content after the selected elements.before()inserts content before the selected elements.
$(function() {
$("#demo").append("kamal");
});$(function() {
$("#demo").prepend("David kamal");
});$(function() {
$("#demo").before("<i>this is before</i>");
$("#demo").after("<b>after ending</b>");
});