相关疑难解决方法(0)

如何为"选择"框创建占位符?

我正在使用占位符进行文本输入,这很好.但我也想为我的选择框使用占位符.当然我可以使用这段代码:

<select>
    <option value="">Select your option</option>
    <option value="hurr">Durr</option>
</select>
Run Code Online (Sandbox Code Playgroud)

但是"选择你的选项"是黑色而不是光线.所以我的解决方案可能是基于CSS的.jQuery也很好.

这只会使下拉列表中的选项变为灰色(因此点击箭头后):

option:first {
    color: #999;
}
Run Code Online (Sandbox Code Playgroud)

编辑:问题是:人们如何在选择框中创建占位符?但它已经得到了回答,欢呼.

使用此选项会导致所选值始终为灰色(即使选择了实际选项后):

select {
    color: #999;
}
Run Code Online (Sandbox Code Playgroud)

html css html-select placeholder

1426
推荐指数
29
解决办法
140万
查看次数

JQUERY检查INPUT文本值是否为空并提示警报

如果单击"提交"按钮,输入字段的值为空,如何使用JQUERY显示警报?

<input type="text" id="myMessage" name="shoutbox_msg" size="16" class="field_nosize" maxlength="150">&nbsp;
<input id="submit" type="submit" name="submit_post" class="button_nosize" value="Senden" onclick="sendMessage(); clearInput();">
Run Code Online (Sandbox Code Playgroud)

javascript forms validation jquery submit

15
推荐指数
2
解决办法
22万
查看次数

使用 jQuery 检查值是否为 null

我试图检查变量的值是否为空,但它不起作用。我还必须停止脚本并且不要插入行

网页

<input type="text" name="for_intitule" id="form_intitule">
Run Code Online (Sandbox Code Playgroud)

jQuery

var form_intitule = $('input[name=form_intitule]').val();

if(form_intitule == null){
  alert('fill the blank');
  return false;
}
Run Code Online (Sandbox Code Playgroud)

更新 :

$('#insertForm').on('click', function(){
  var form_intitule = $('input[name=form_intitule]').val();

  if($('input[name=form_intitule]').val().trim().length == 0){
    alert('fill the blank');
  }
  $.ajax({
    type: "GET",
    url: "lib/function.php?insertForm="+insertForm+"&form_intitule="+form_intitule,
    dataType : "html",
    error: function(XMLHttpRequest, textStatus, errorThrown) {
      alert(XMLHttpRequest + '--' + textStatus + '--' + errorThrown);
    },
    success:function(data){
    }
  });
});
Run Code Online (Sandbox Code Playgroud)

jquery

3
推荐指数
1
解决办法
3万
查看次数

我希望隐藏字段,如果它的值为空,则图像src也使用Javascript在HTML中

如果字段为空并且图像src也是如何隐藏html中的字段.使用java脚本.请建议

<div id="pagewrapper" >
    <div class="row" >
        <div class="column-half" style="width:500px">
            <div class="containerdiv" >

                <form:label path="file4Desc" type="text" value="" maxlength="50">
                </form:label>
                <form:input path="file4Desc" value="${agreement.file4Desc}" 
                    style="width:300px"/>
                <font color="red"><form:errors path="file4Desc" /></font>           
            </div>
        </div>
        <div class="column-half" style="width:13%">         
            <div class="containerdiv">
                <form:label path="filename3" type="text" value="" maxlength="50">
                </form:label>
                <a href="${pageContext.request.contextPath}/customer/viewDownload3/${agreement.agreementId}.htm">
                    <img src="${pageContext.request.contextPath}/resources/images/download3.gif" 
                                border="0"
                                title="Download this document"/>
                </a>

            </div>
        </div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

0
推荐指数
1
解决办法
2107
查看次数

标签 统计

jquery ×3

html ×2

javascript ×2

css ×1

forms ×1

html-select ×1

placeholder ×1

submit ×1

validation ×1