Wednesday, July 14, 2010

removeAttr(), jQuery

Html Tags can have various Attributes.  You can use removeAttr() Method from jQuery to to remove one or more attributes .

Syntax:
$("Selector").removeAttr("AttributeName");

See the example below.









<head>
<style type='text/css'>


</style>


<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script>
<script type='text/javascript'>
$(document).ready(function(){
$('#da').click(function(){
$('a').removeAttr('title')
})

})

</script>
</head>

<body>
<a href='http://interactivefrench.blogspot.com/' title='Learn French Language Free and Interactively'>Free French</a>
<br>
<button type='button' id='da'>Click to Remove Title Attribute</button>
</body>
</html>




By positiong the mouse over the link a description will appear,(Tittle attribute). After you click the button, the description will disappear.



Free French




No comments:

Post a Comment