Change Placeholder Text using jQuery

后端 未结 13 1294
-上瘾入骨i
-上瘾入骨i 2020-12-04 06:17

I am using a jQuery placeholder plugin(https://github.com/danielstocks/jQuery-Placeholder). I need to change the placeholder text with the change in dropdown menu. But it is

13条回答
  •  孤街浪徒
    2020-12-04 06:59

    Moving your first line to the bottom does it for me: http://jsfiddle.net/tcloninger/SEmNX/

    $(function () {
        $('#serMemdd').change(function () {
            var k = $(this).val();
            if (k == 1) {
                $("#serMemtb").attr("placeholder", "Type a name (Lastname, Firstname)").placeholder();
            }
            else if (k == 2) {
                $("#serMemtb").attr("placeholder", "Type an ID").placeholder();
            }
            else if (k == 3) {
                $("#serMemtb").attr("placeholder", "Type a Location").placeholder();
            }
        });
        $('input[placeholder], textarea[placeholder]').placeholder();
    });
    

提交回复
热议问题