开发者

Alternative select box with jquery

I'm trying to make the a selectable list like a select-box, so when you click on the li a, change the label for the selected li a.

First of all, this is possible? Here is the code: http://jsfiddle.net/dcalixt开发者_开发知识库o/h8esW/10/

Thank's for any hint :)


Definitely possible using the text() method.

$(".genero-box li").click(function() {
    $genero = $('.genero');  /* Get the <label> */
    $genero.text($(this).text()); /* Set <label>'s text to clicked <li>'s text */
    $genero.click(); /* Trigger a click on the label to close the selection */
});

Here's an update to your code.


This probably is what you're looking for:

$(".genero-box li").click(function(e) {
    $("label.genero").text($(this).text());
    $(".genero-box").fadeOut();
});

Check kthis jsFiddle - http://jsfiddle.net/FloydPink/tyHSx/1/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜