Hello,
remember to include jQuery library before the javascript code below.
here is the code:
JS/Jquery:
if($('.faq-post').length){
var self = $('.faq-body');
$('.faq-body .faq-answer').hide();
$('.faq-question').on('click',function(e){
$('.faq-answer').hide();
$(this).next().show();
e.preventDefault();
return false;
});
}
HTML:
<article class="col-xs-12">
<div class="faq-body">
<h5 class="faq-question"><a href="#" title="">Topic heading </a></h5>
<div class='faq-answer'>Content</div>
</div>
</article>
You can add you style as you wish.
Enjoy!!!
Follow me on twitter: http://www.twitter.com/_josiah_king
Join me on Google+: https://www.plus.google.com/u/0/113541005774136102412/posts/p/pub?cfem=1
Showing posts with label jquery. Show all posts
Showing posts with label jquery. Show all posts
Monday, 1 February 2016
Saturday, 24 January 2015
How to check if value is a number (isNumer()) in javascript
After Stubbling at this challenge, i googled and found different solutions include the jQuery implementation of this, but none seems to do what i wanted, they either return true or false.
I wanted to know if a value is a number whether it's a typeof string or number. The codes below did the job very well, unlike !isNaN() or $.IsNumeric() which return true in the case of newline or space.
var isNumber = function(v){
//return typeof v === 'number' && isFinite(v);
return !isNaN(parseFloat(v)) && isFinite(v);
}
The commented code is the yahoo UI implementation which i tried but didn't give me what i wanted.
Return false if typeof is 'string' while true if typeof is 'number'. But the uncommented code does the job.
Than you for reading. Please post your comment.
I wanted to know if a value is a number whether it's a typeof string or number. The codes below did the job very well, unlike !isNaN() or $.IsNumeric() which return true in the case of newline or space.
var isNumber = function(v){
//return typeof v === 'number' && isFinite(v);
return !isNaN(parseFloat(v)) && isFinite(v);
}
The commented code is the yahoo UI implementation which i tried but didn't give me what i wanted.
Return false if typeof is 'string' while true if typeof is 'number'. But the uncommented code does the job.
Than you for reading. Please post your comment.
Subscribe to:
Posts (Atom)