Some simple examples use native js and jQuery to change div attributes and reset them at will. The code is as follows:
Function passes parameters to change the value of any attribute of Div Enter "attribute name" in the upper input box and "Attribute Value", click the OK button to view the effect.
$(function(){
$("button:first").click(function() {
var styleName= $("#outer").find("input:first").val();
var styleVal = $("#outer").find("input:last") .val();
$("#div1").css(styleName,styleVal);
})
$("button:last").click(function(){
$ ("#div1").removeAttr("style");
})
})
< ;body>
Enter "attribute name" and "attribute value" in the upper input box, and click the OK button to view the effect.