-
Notifications
You must be signed in to change notification settings - Fork 0
/
hugor.js
40 lines (35 loc) · 815 Bytes
/
hugor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* jQuery */
$(function() {
var readMore = function() {
btn = $(this);
btn.prev('.more').show(1000);
btn.text('Read Less');
btn.unbind('click');
btn.bind('click', readLess);
}
var readLess = function() {
btn = $(this);
btn.prev('.more').hide(1000);
btn.text('Read More');
btn.unbind('click');
btn.bind('click', readMore);
}
$('.btn').bind('click', readMore);
});
/* pure javascript */
/* old code */
/*var moreText = document.querySelectorAll('.more');
var btnText = document.querySelectorAll('.btn');
function readMore(i)
{
if (moreText[i].style.display === 'inline')
{
btnText[i].innerHTML = 'Read more';
moreText[i].style.display = 'none';
}
else
{
btnText[i].innerHTML = 'Read less';
moreText[i].style.display = 'inline';
}
}*/