admin管理员组文章数量:1022496
I came across this great JQuery example of using a slidetoggle.
I want to implement it exact as is, except for one thing.
The example uses an image for the Up and Down (white) arrow indicator.
Can't I use the HTML ascii up arrow (↑) and down arrow (↓) instead of using an image.
If so, how?
I came across this great JQuery example of using a slidetoggle.
I want to implement it exact as is, except for one thing.
The example uses an image for the Up and Down (white) arrow indicator.
Can't I use the HTML ascii up arrow (↑) and down arrow (↓) instead of using an image.
If so, how?
Share Improve this question asked Apr 23, 2010 at 6:33 TimjTimj 14.3k3 gold badges20 silver badges9 bronze badges3 Answers
Reset to default 4I believe something like this should work:
$(".btn-slide").click(function(){
$("#panel").slideToggle("slow");
$(this).toggleClass("active");
//Toggle text here (I may have the up/down order inverted)
$(".btn-slide").toggle(function() {
$(this).text('Slide ↑');
}, function() {
$(this).text('Slide ↓');
});
return false;
});
Basically the idea is just to toggle the text on the link when it is clicked, the same place the author toggles the up/down slide.
More info on toggle() here.
You will also need to remove the white background image from here:
.btn-slide {
background:url("images/white-arrow.gif") no-repeat scroll right -50px
HTH
You can change the text value of the anchor element as follows.
$(".btn-slide").click(function(){
$("#panel").slideToggle("slow");
$(this).toggleClass("active"); return false;
$(this).text('YourText ' + ($(this).hasClass('active') ? '↑' : '↓'));
});
Removing the arrow image is done by eliminating the CSS background
property of the .btn-slide
selector.
in my case, i prefer use attribute .attr()
$(this).attr('value', '↑');
When testing using firebug, i use .val()
or .html()
, after <input>
will add extra </input>
. Its not work for me.
Sorry my bad English.
I came across this great JQuery example of using a slidetoggle.
I want to implement it exact as is, except for one thing.
The example uses an image for the Up and Down (white) arrow indicator.
Can't I use the HTML ascii up arrow (↑) and down arrow (↓) instead of using an image.
If so, how?
I came across this great JQuery example of using a slidetoggle.
I want to implement it exact as is, except for one thing.
The example uses an image for the Up and Down (white) arrow indicator.
Can't I use the HTML ascii up arrow (↑) and down arrow (↓) instead of using an image.
If so, how?
Share Improve this question asked Apr 23, 2010 at 6:33 TimjTimj 14.3k3 gold badges20 silver badges9 bronze badges3 Answers
Reset to default 4I believe something like this should work:
$(".btn-slide").click(function(){
$("#panel").slideToggle("slow");
$(this).toggleClass("active");
//Toggle text here (I may have the up/down order inverted)
$(".btn-slide").toggle(function() {
$(this).text('Slide ↑');
}, function() {
$(this).text('Slide ↓');
});
return false;
});
Basically the idea is just to toggle the text on the link when it is clicked, the same place the author toggles the up/down slide.
More info on toggle() here.
You will also need to remove the white background image from here:
.btn-slide {
background:url("images/white-arrow.gif") no-repeat scroll right -50px
HTH
You can change the text value of the anchor element as follows.
$(".btn-slide").click(function(){
$("#panel").slideToggle("slow");
$(this).toggleClass("active"); return false;
$(this).text('YourText ' + ($(this).hasClass('active') ? '↑' : '↓'));
});
Removing the arrow image is done by eliminating the CSS background
property of the .btn-slide
selector.
in my case, i prefer use attribute .attr()
$(this).attr('value', '↑');
When testing using firebug, i use .val()
or .html()
, after <input>
will add extra </input>
. Its not work for me.
Sorry my bad English.
本文标签: javascriptJQuery How to use an HTML ascii arrow for a toggle indicatorStack Overflow
版权声明:本文标题:javascript - JQuery: How to use an HTML ascii arrow for a toggle indicator? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745475858a2152319.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论