大家好,我可以从我的jquery插入一个值。
这是我的html和jquery代码请帮我提前谢谢!!!
< script >
$(document).ready(function() {
$("#oroom").blur(function() {
var oroom = $("#oroom").val();
var capa = $("#rcapa").val();
if (oroom.lenght == capa.lenght) {
$("#rcapa").html("Capacity of 1 - 16 person");
}
});
}); < /script>
<div class="form-group" style="margin-left:100px;">
<div class="col-sm-10">
Occupied Rooms:
<select class="form-control" name="room" id="oroom">
<option>Occupied Room</option>
<option id="1room">1 Room</option>
<option>2 Rooms</option>
<option>3 Rooms</option>
</select>
</div>
</div>
<div class="form-group" style="margin-left:100px;">
<div class="col-sm-10">
Rooms Capacity:
<input type="text" class="form-control" id="rcapa" disabled>
</div>
答案 0 :(得分:2)
使用val()
代替html()
作为输入元素
替换
$("#rcapa").html("Capacity of 1 - 16 person");
通过
$("#rcapa").val("Capacity of 1 - 16 person");
答案 1 :(得分:2)
$("#rcapa").val("Capacity of 1 - 16 person");
.html()
会将其innerHTML
设置为传递的值。由于input
元素是void
元素(它不能包含任何元素作为其子元素),因此innerHTML
将被忽略。
答案 2 :(得分:2)
答案 3 :(得分:2)
.html()用于设置/获取HTML内容,而.val()用于获取/赋值控件
$("#rcapa").val("Capacity of 1 - 16 person"); // assign the value to the control
使用这个
...
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
VideoView mVideoView = (VideoView) findViewById(R.id.videoView);
mVideoView.setVideoPath("file:///android_asset/video1.MP4");
mVideoView.setMediaController(new MediaController(this));
mVideoView.seekTo(1);
//mVideoView.requestFocus();
}