How does javascript-JQ associate two tags?

Source: Internet
Author: User
{Code...} Suppose that divabc has been hidden. The result I want to achieve is that the diva shown below is triggered when I click A in li. Click B to trigger the following divb. How does one map li (a) to div (? Because PHP will be used to loop through this code, {code .....

  • a
  • b
  • c

a

b

c

Assume that p abc has been hidden.
The result I want to achieve is that when I click A in li, the following p a is displayed. When B is clicked, the following p B is triggered. How does one correspond li (a) to p (?
Because PHP will be used to loop through the code,

  • a

a

How can we trigger the corresponding p display no matter how many cycles?

Reply content:

  • a
  • b
  • c

a

b

c

Assume that p abc has been hidden.
The result I want to achieve is that when I click A in li, the following p a is displayed. When B is clicked, the following p B is triggered. How does one correspond li (a) to p (?
Because PHP will be used to loop through the code,

  • a

a

How can we trigger the corresponding p display no matter how many cycles?

First, we recommend that you use data-Attribute. However, you are not using data-, Then I will first correspond according to the order.
The following is the corresponding p automatic toggle after you press the label. You can change it according to your needs.

$('#navbb').find('ul').on('click', 'a', function(event) {    var index = $(event.currentTarget).parent().index();    $('#navbb p:eq(' + index + ')').toggle()})

Http://segmentfault.com/q/1010000002537374

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.