Change Placeholder Text using jQuery

后端 未结 13 1229
-上瘾入骨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:39

    If the input is inside the div than you can try this:

    $('#div_id input').attr("placeholder", "placeholder text");
    
    0 讨论(0)
  • 2020-12-04 06:41

    change placeholder text using jquery

    try this

    $('#selector').attr("placeholder", "Type placeholder");
    
    0 讨论(0)
  • 2020-12-04 06:46
    $(document).ready(function(){ 
      $('form').find("input[type=search]").each(function(ev)
      {
         $(this).attr("placeholder", "Search Whatever you want");
      });
    });
    
    0 讨论(0)
  • 2020-12-04 06:47

    working example of dynamic placeholder using Javascript and Jquery http://jsfiddle.net/ogk2L14n/1/

    <input type="text" id="textbox">
     <select id="selection" onchange="changeplh()">
         <option>one</option>
         <option>two</option>
         <option>three</option>
        </select>
    
    function changeplh(){
        debugger;
     var sel = document.getElementById("selection");
        var textbx = document.getElementById("textbox");
        var indexe = sel.selectedIndex;
    
        if(indexe == 0) { 
         $("#textbox").attr("placeholder", "age");
    
    }
           if(indexe == 1) { 
         $("#textbox").attr("placeholder", "name");
    }
    }
    
    0 讨论(0)
  • 2020-12-04 06:48
    $(document).ready(function(){ 
      $('form').find("input[type=textarea], input[type=password], textarea").each(function(ev)
      {
          if(!$(this).val()) { 
         $(this).attr("placeholder", "Type your answer here");
      }
      });
    });
    

    Copy and paste this code in your js file, this will change all placeholder text from whole site.

    0 讨论(0)
  • 2020-12-04 06:48

    try this

    $('#Selector_ID').attr("placeholder", "your Placeholder");
    
    0 讨论(0)
提交回复
热议问题