当我将值设置为value =“{”filename“:”Image1.png“,”status“:”SUCCESS“}
时,只打印第一个字符,即”{“如何获取完整字符串{“filename”:“Image1.png”,“status”:“SUCCESS”}
$(function(){
$("button").on("click", function(){
var t = $(this).closest('.parentDiv').children("input[name='toFind']").val();
console.log(t);
})
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="parentDiv" >
<input type="hidden" name="toFind" value=" {"filename":"Image1.png","status":"SUCCESS"}">
<div class="btn-group">
<button class="button" type="button" >Remove</button>
</div>
</div>