Can I add an <a href="">
link to an HTML element using CSS. As I have an image which I want to add a link to a particular page. Can any one help me in doing this?
You can refer that. $('#link'). attr('href','http://www.google.com'); This single line will do the trick.
Short answer no, in css you can't create content or display it multiple times. Usually this repeated content is taken care of via server side technologies (PHP, JSP, ASPX) etc. If your site is static content (no server side processing) then your best bet is just copy and past.
Divs are HTML elements that are delineated with the tags <div> and </div>. Attributes are key/value properties that are attached to an element like so <a href=”this is the value of the href attribute”>. You cannot use a tag as an attribute or attribute value.
The :link selector is used to select unvisited links. Note: The :link selector does not style links you have already visited. Tip: Use the :visited selector to style links to visited pages, the :hover selector to style links when you mouse over them, and the :active selector to style links when you click on them.
No. Its not possible to add link through css. But you can use jquery
$('.case').each(function() {
var link = $(this).html();
$(this).contents().wrap('<a href="example.com/script.php?id="></a>');
});
Here the demo: http://jsfiddle.net/r5uWX/1/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With