Click On Link To Show Data On Div And Link Disappear Is Not Working
What I need I need when user click on link data is shown. link disappear after click. I have tried code
Solution 2:
Try the following:
$('.viewdetail').click(function()
{
$('.speakers').show();
$(this).hide();
});
$(this)
refers to the .viewdetail
so you don't need the find
it again
Pull the div outside the hyperlink
HTML:
<a href="javascript:void(0);" class="viewdetail more" style="color:#8989D3!important;">view details</a>
<div class="speakers dis-non"></div>
Solution 3:
First of all this
in your code refers to to the clicked link itself.
So this line $(this).find('.viewdetail').hide();
doesn't work, because there is no .viewdetail
inside of link. It should be
$('.viewdetail').on('click',function(e) {
var self = $(this);
self.find('.speakers').show();
self.hide();
});
But, if you hide your link, the .speakers
will be also hidden, because it's inside of your link. If you want it to be visible, you should place it outside of link
For example:
<a href="#" class="viewdetail more" style="color:#8989D3!important;">view details</a>
<div class="speakers dis-non"></div>
And JS:
$('.viewdetail').on('click',function(e) {
var self = $(this);
e.preventDefault(); // prevent link from working the way it should
self.next('.speakers').show();
self.hide();
});
Post a Comment for "Click On Link To Show Data On Div And Link Disappear Is Not Working"