Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

jQuery .attr() method

0 votes
23 views
added Apr 2 in jQuery by LC Marshal Lieutenant (13,870 points)

Find element and change the href value

$(".button a").attr("href", "http://www.hormart.com/");

5 Responses

0 votes
responded Apr 3 by LC Marshal Lieutenant (13,870 points)

To change breadcrumb link no.3 to use PHP variable to replace the existing link

var lookfordistrict = $('ol.breadcrumb li:nth-child(3) a'); 
var districtlink = "/map-search-property?listing_type=<?php print $field_prop_listing_type; ?>&state=<?php print $field_state; ?>&district=<?php print $field_district; ?>";
$(lookfordistrict).attr('href', districtlink);
0 votes
responded Apr 10 by LC Marshal Lieutenant (13,870 points)
// Add id attribute to element
$(detailcontent).attr('id', 'property-detail-content'); 
0 votes
responded May 4 by LC Marshal Lieutenant (13,870 points)
//Manipulate attr for img source
$('#arrow-3').attr('src','https://yoursite.com/images/arrow_down.png');
0 votes
responded May 4 by LC Marshal Lieutenant (13,870 points)
//Change hyperlink value
$("#link").attr('href', 'https://hormart.com');
0 votes
responded May 7 by LC Marshal Lieutenant (13,870 points)
// attribute for data
var hormatLink = $('.header-nav a[href="http://hormart.com/"]');
hormatLink .attr("data-placement","bottom");
lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...