javascript - replace tag content using jquery -



javascript - replace tag content using jquery -

in html have code:

<div class="selfclear"> <h3><a id="lnkname" href="/dir/subdir/?id=577">name</a></h3> <address> street name, 3 <br />3222 city<br />phone. : 0202 777 876 </address> </div>

i want replace phone number depending on id passed url within tag using jquery.

so far able id doing so:

function getid(){ var = $('#lnkname').attr('href').split('='); var id= a[1]; }

and content of :

function print_address(){ var div = $('#lnkname'); if (!div.length) return; var adress = $('#lnkname').parent().siblings('address').html(); adress.replace( '/phone : .*/', '/phone : 777' ); var newtel = $('#lnkname').parent().siblings('address').html( adress ); div.html(newtel).show('slow',function(){ }); }

the problem replacing function print_address() print me content of address not load new content

thanks help

you replace 777 id number href?

if can not following?

<script> $(function() { var = $('#lnkname').attr('href').split('='); var id= a[1]; $('#phone-number').text(id); }); </script> <div class="selfclear"> <h3><a id="lnkname" href="/dir/subdir/?id=577">name</a></h3> <address>street name, 3 <br />3222 city<br />phone. : 0202 <span id="phone-number">777</span> 876</address> </div>

javascript jquery

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -