jqueryexample.com jQuery example - replace id of an element - jqueryexample.com

jQuery example – replace id of an element by jqueryexample

Below is a simple code to replace id selector from an element.
<html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('#leftNav').attr('id', 'topNav'); }); </script> <style>#topNav{color:red;}</style> </head> <body> <p id="nav">If you click on me, I will disappear.</p> </body> </html>

Did you like this? Share it:

Discussion

No comments yet, be the first.

Leave a Comment