Use jQuery to implement @ ID floating display of comments in WordPress _ jquery

Source: Internet
Author: User
This article mainly introduces how to use JavaScript to implement the function of displaying comments by ID in WordPress, that is, to display the subject content of the comments in the building-style comments. For more information, see: A left A message and B replied to A with @, so B's reply may be like this:

@
How much money do you have?

That is to say, when you hover the mouse over @ A, the comment of A will be displayed in A floating area.

Steps
Here we will take the iNove topic as an example.
1. Save the following code as commenttips. js:

jQuery(document).ready( function(){ var id=/^#comment-/; var at=/^@/; jQuery('#thecomments li p a').each(  function() {  if(jQuery(this).attr('href').match(id)&& jQuery(this).text().match(at)) {   jQuery(this).addClass('atreply');  }  } ); jQuery('.atreply').hover(  function() {  jQuery(jQuery(this).attr('href')).clone().hide().insertAfter(jQuery(this).parents('li')).attr('id','').addClass('tip').fadeIn(200);  },   function() {  jQuery('.tip').fadeOut(400, function(){jQuery(this).remove();});  } ); jQuery('.atreply').mousemove(  function(e) {  jQuery('.tip').css({left:(e.clientX+18),top:(e.pageY+18)})  } ); })

2. Place the commenttips. js file in the inove/js directory.

3. the append style code in style.css is as follows:

#thecomments .tip { background:#FFF; border:1px solid #CCC; width:605px; padding:10px !important; padding:10px 10px 0; margin-top:0; position:absolute; z-index:3;}#thecomments .tip .act { display:none;}*+html #thecomments .tip { padding:10px 10px 0 !important;}

4. add code in the topic to call JavaScript. open templates/end. phpAdd the following code in the previous line:
(If you have other plug-ins or you have added jQuery libraries, you do not need to add the first line of code .)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.