Catch value(s) with jQuery
I have this snippet below, but I don't know how to catch value(s) with jQuery
. How could we get some values from input text?
<script type="text/javascript">
$(document).ready(function() {
$("#fileInput2").uploadify({
//How get value from input (fileInput2)
});
});
</script>
<div class="demo">
<input id="fileInput2" name="fileInput2" type="file" />
<a href="javascript:$('#fileInput2').uploadifyUpload();">Upload Files</a>
</div>
开发者_StackOverflow中文版
<script type="text/javascript">
$(document).ready(function()
{
$("#fileInput2").uploadify(
{
// Get value
var input_field_value = $(this).val()
});
});
</script>
<div class="demo">
<input id="fileInput2" name="fileInput2" type="file" />
<a href="javascript:$('#fileInput2').uploadifyUpload();">Upload Files</a>
</div>
EDIT
You are calling the uploadify
function on fileInput2
, so if you write $(this)
, it will refer to this same element, which is fileInput2
textbox. So writing $(this).val()
will give you the value of this input element.
Use the val()
method:
$("#fileInput2").val();
Or:
$("#fileInput2").uploadify({
alert($(this).val());
});
精彩评论