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

jQuery .html() method

0 votes
28 views
added Mar 28 in jQuery by FeruzRahim Lance Corporal (780 points)
edited Apr 6 by LC Marshal

Find element and add/change html of it

$('#area-outlook-link').html('<a href="http://google.com">Google</a>');

5 Responses

0 votes
responded Apr 5 by LC Marshal Lieutenant (13,450 points)
edited Apr 6 by LC Marshal

Click element, and change element with .html() method

$("button").click(function(){
    $("p").html("Hello <b>world</b>!");
});
0 votes
responded Apr 5 by LC Marshal Lieutenant (13,450 points)
edited Apr 6 by LC Marshal

Change #regTitle element wih .html() method for JS & jQuery

document.all.regTitle.innerHTML = 'Hello World';
$("#regTitle").html("Hello World");
0 votes
responded Apr 9 by LC Marshal Lieutenant (13,450 points)
edited Apr 9 by LC Marshal
<a id="search-listing" target="_blank" href="/map-search-property?&keyword=">
  <button class="button white">Search for listings</button>
</a>


<script>
    //jQuery
    var projectname = $('h1.page-header').text();
    var x = "/map-search-property?&keyword=";
    var y = projectname.substr(0, projectname.indexOf(','));
    var result = x + y;

    $('a#search-listing').attr('href', result);
</script>

 

0 votes
responded Apr 20 by LC Marshal Lieutenant (13,450 points)

Change content of element with other element

var header = $('h1.page-header');
var forumQ = $('.field-type-text-with-summary > .field-items');

$(header).html(forumQ);
0 votes
responded Apr 26 by LC Marshal Lieutenant (13,450 points)

Replace .forum-category element with forumSubCat

var forumSubCat = $('ol.breadcrumb li:nth-child(3) a');
$('span.forum-category').html(forumSubCat);
lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...