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
58 views
added Apr 2 in jQuery by LC Marshal Lieutenant (14,830 points)

Find element and change the href value

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

6 Responses

0 votes
responded Apr 3 by LC Marshal Lieutenant (14,830 points)
edited Oct 31 by LC Marshal

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 (14,830 points)
edited Oct 31 by LC Marshal
// Add id attribute to element
$(detailcontent).attr('id', 'property-detail-content'); 
0 votes
responded May 4 by LC Marshal Lieutenant (14,830 points)
edited Oct 31 by LC Marshal
//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 (14,830 points)
edited Oct 31 by LC Marshal
//Change hyperlink value
$("#link").attr('href', 'https://hormart.com');
0 votes
responded May 7 by LC Marshal Lieutenant (14,830 points)
edited Oct 31 by LC Marshal
// attribute for data
var hormatLink = $('.header-nav a[href="http://hormart.com/"]');
hormatLink .attr("data-placement","bottom");
0 votes
responded Oct 31 by LC Marshal Lieutenant (14,830 points)
// change href attr to new value
(function() {
    $(document).ready(function() {
        var a = $("#checkin").attr("href");
        $("#sidr ul li:eq(2) a").attr("href", a)
    })
})();

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...