所以我有这段代码:
<script type="text/javascript">
$(document).ready(function() {
$('.rm_color').each(function() {
var divPicker = $(this).find('.colorpicker');
var inputPicker = $(this).find('input[type=text]');
divPicker.hide();
divPicker.click(function(){divPicker.farbtastic(inputPicker)});
});
});
</script>
我的目的是隐藏远程功能,但是当使用双击textarea输入时,就会显示远程功能。当用户再次双击它时,farbstastic会被隐藏。
如何使用上面的代码创建正确的代码?非常感谢
已更新!答案:
我找到了答案:
<script type="text/javascript">
$(document).ready(function() {
$('.rm_color').each(function() {
var divPicker = $(this).find('.colorpicker2');
var inputPicker = $(this).find('input[type=text]');
divPicker.hide();
divPicker.farbtastic(inputPicker);
inputPicker.dblclick(function(){divPicker.slideToggle()});
});
});
</script>
如果您从远程官方网站上获取原始声明脚本,这是修改后的代码。
http://acko.net/dev/farbtastic
<script type="text/javascript">
$(document).ready(function() {
$('#colorpicker4').hide();
$('#colorpicker4').farbtastic('#color4');
$('#color4').dblclick(function(){$('#colorpicker4').slideToggle()});
});
</script>
答案 0 :(得分:0)
http://api.jquery.com/dblclick/
<script type="text/javascript">
var isOpen = false;
$(document).ready(function() {
$('.rm_color').each(function() {
var divPicker = $(this).find('.colorpicker');
var inputPicker = $(this).find('input[type=text]');
divPicker.hide();
divPicker.dblclick(function(){
if(isOpen){
//close
isOpen = false;
}else{
divPicker.farbtastic(inputPicker)
isOpen = true;
}
});
});
});
</script>
答案 1 :(得分:0)
试试这个
<script type="text/javascript">
$(document).ready(function() {
$('.rm_color').each(function() {
var divPicker = $(this).find('.colorpicker');
var inputPicker = $(this).find('input[type=text]');
divPicker.hide();
inputPicker.dbclick(function(){ divPicker.toggle(); if(divPicker.is(":visible")){
divPicker.farbtastic(inputPicker);}
});
});
});
</script>
答案 2 :(得分:0)
我找到了答案:
<script type="text/javascript">
$(document).ready(function() {
$('.rm_color').each(function() {
var divPicker = $(this).find('.colorpicker2');
var inputPicker = $(this).find('input[type=text]');
divPicker.hide();
divPicker.farbtastic(inputPicker);
inputPicker.dblclick(function(){divPicker.slideToggle()});
});
});
</script>
如果您从远程官方网站上获取原始声明脚本,这是修改后的代码。
http://acko.net/dev/farbtastic
<script type="text/javascript">
$(document).ready(function() {
$('#colorpicker4').hide();
$('#colorpicker4').farbtastic('#color4');
$('#color4').dblclick(function(){$('#colorpicker4').slideToggle()});
});
</script>