Handle Controls Attribute using jQuery
Introduction
This
post shows how to handle or target controls attribute using jQuery. We already talked
how to modify the appearance of controls on web page when user, hover the mouse
or click the mouse. For this we used .addClass(),.removeClass(),.css(), .toggleClass()
etc.
I'm
going to cover some cool stuffs using problem to solution approach. So, let's
start and look at first problem.
Problem 1
If you
simply want to open all URLs on new tab, a quick jQuery code can do this using .attr()
method.
Note: For more read this.
.attr()
Method
.attr()
gets the value of an attribute for the first element in the set of matched
elements.
Problem 2
If you
have a website that uses huge list of images there and forgot to place alt
(alternative) text (when image not found, that will be displayed), how to fix this.
I mean how you will add a brand new attribute to existing list of controls?
Don't
worry, here it the fix.
Look at
result in browser.
Comments
Post a Comment