开发者

Use Farbtastic with classes instead of id's

I've got:

<input type="text" id="color1" value="<?php echo get_option('color1'); ?>" name="color_picker_color1" /><div class="farbtastic_color_picker"></div>
<input type="text" id="color2" value="<?php echo get_option('color2'); ?>" name="color_picker_color2" /><div class="farbtastic_color_picker"></div>

with:

<script type="text/javascript">
    jQuery('.farbtastic_color_pic开发者_如何学Goker').hide();
    jQuery('.farbtastic_color_picker').farbtastic("#color1");
    jQuery("#color1").click(function(){jQuery('.farbtastic_color_picker').slideToggle()});
</script>

What do I need to change in the script section, so I don't have to duplicate the code? Now it's only for the text iput with #color1. I'd like to use the code on multiple #'s (color1, color2, color3 etc).


You can use the Attribute Starts With Selector:

jQuery('input[name^="color_picker_color"]')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜