<label for="id_zip_code">
Zip code:
</label>
How to add using jquery a href
for this label?
Excepted output:
<a href="http://google.com"><label for="id_zip_code">Zip code:</label></a>
<label for="id_zip_code">
Zip code:
</label>
How to add using jquery a href
for this label?
Excepted output:
<a href="http://google.com"><label for="id_zip_code">Zip code:</label></a>
Try
$('label[for="id_zip_code"]').wrap('<a href="http://google.com"><a/>')
try
$('label[for=id_zip_code]').wrap($('<a />', {href: "http://google.com"}));
Use wrap()
:
$('label').wrap($('<a></a>', {
'href': 'http://www.google.com'
});
Obviously, you'd be best to make the label
selector more specific by adding a class or id to the element.
Use wrapInner
<label id="somelable" for="id_zip_code">
Zip code:
</label>
$("#somelable").wrapInner("<a href=http://google.com></a>");