开发者

replace span with new data but new jquery call is not working

开发者 https://www.devze.com 2023-02-28 16:15 出处:网络
I have a big problem with this situation. I\'ve been looking for this problem for a week and I don\'t find the answer. If someone knows how can I solve it, I really appreciate. I\'m a newby in jQuery.

I have a big problem with this situation. I've been looking for this problem for a week and I don't find the answer. If someone knows how can I solve it, I really appreciate. I'm a newby in jQuery.

My problem is simple:

I find and replace what I need to replace but the new data link doesn't call the jQuery function ej like for unlike the first like works but when it is replaced for unlike you click unlike and doesn't call the function jQuery.

/// like 
$('.like').livequery("click",function(e){
    var getID   =  $(this).attr('id').replace('post_idpl','');
    $.post("2.php?p_idpl="+getID, {             
    }, function(response){
        $('span', 'div.like-head'+getID).html('<a href="javascript: void(0)" id="post_idpl'+getID+'" class="unlike">Unlike</a>');
    });
}); 

/// unlike 
$('.unlike').livequery("click",function(e){
    var getID   =  $(this).attr('id').replace('post_idpl','');
    $.post("3.php?p_idpu="+getID, {
    }, function(response){
        $('span', 'div.like-head'+getID).html('<a href="javascript: void(0)" id="post_idpl'+getID+'" class="like"&g开发者_运维问答t;Like</a>');
    });
}); 
// ]]>


It's not really clear what you want, but i suspect using .live('click',function(){... instead of .click(function(){... function may solve you problem, see here

.live() method is able to affect elements that have not yet been added to the DOM through the use of event delegation: a handler bound to an ancestor element is responsible for events that are triggered on its descendants.


It is an example of parsing float value. Look for your appropriate function in the jQuery documentation.

var val = parseFloat( document.getElementById('your_id_tag').innerHTML );
0

精彩评论

暂无评论...
验证码 换一张
取 消