Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 283
  • Last Modified:

a link tag not working

If you check my previous example code i selected as an answer!

whenever i add the <a> href tag, the Expand /Collapse Stops Working

Can Anybody Check Please
0
Gurpreet Singh Randhawa
Asked:
Gurpreet Singh Randhawa
  • 4
  • 3
1 Solution
 
Sudaraka WijesingheWeb Application ProgrammerCommented:
please post a link to your previous example code
0
 
Gurpreet Singh RandhawaWeb DeveloperAuthor Commented:
0
 
Gurpreet Singh RandhawaWeb DeveloperAuthor Commented:
used this answer:

35386418
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Sudaraka WijesingheWeb Application ProgrammerCommented:
Thanks for the link.

Problem there is that when you add the A tag it alters the DOM structure putting some selectors in the jQuery code off track.

In the expand function, find the line
$(obj).next("div").show("fast")

Open in new window

and change it to
$(">div", $(obj).parent()).show("fast")

Open in new window

or
$(obj).siblings("div").show("fast")

Open in new window


Do the same to the collapse function.

function expand(obj) {

        //show the very next div to the image that was clicked
        //$(obj).next("div").show("fast")

        //$(">div", $(obj).parent()).show("fast")
        $(obj).siblings("div").show("fast")

        //add the collapse image object to the parent of this image (the li)
        $(obj).parent().prepend($collapseIMG.clone());
        //remove the clicked image from the li
        $(obj).remove()
    }

    function collapse(obj) {
        //show the very next div to the image that was clicked
        $(obj).next("div").hide("fast")

        //$(">div", $(obj).parent()).hide("fast")
        $(obj).siblings("div").hide("fast")

        //add the expand image object to the parent of this image (the li)
        $(obj).parent().prepend($expandIMG.clone());
        //remove the clicked image from the li
        $(obj).remove()
    }

Open in new window

0
 
Gurpreet Singh RandhawaWeb DeveloperAuthor Commented:
Thanks But the a link can be outside of div and inside of li will it fix it
0
 
Gurpreet Singh RandhawaWeb DeveloperAuthor Commented:
also creating the sibling is expanding it and collaping it immediately

i have like this

ul>li>then i have the a tag in first time

after that this

ul>li>div>ul>li>a tag i have
0
 
Sudaraka WijesingheWeb Application ProgrammerCommented:
Could you please post the complete code you are having the problem with?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now