我有这个代码:
<input type="hidden" id="editorTitle" name="title" value="home"> <textarea name="text" id="editorText"></textarea>
但是当我写$(‘#editorTitle’).val()和$(‘#editorText’).html(),$(‘#editorTitle’).val()是’undefined’和$(‘#editorText’ ).html()是空的?
哪里不对?
编辑:
这是我的完整代码:
function openEditor() { $("#editor").show().animate({ width: 965,height: 380 },1500); $("#editor textarea").show(); } function closeEditor() { $("#editor").animate({ width: 985,height: 1 },1500,function () { $("#editor").hide(); $("#editor textarea").hide(); }); } function setedit() { $.ajax({ type: "POST",url: "engine.PHP",data: "title=" + $('#editorTitle').attr('value') + "&text=" + $('#editorText').html(),beforeSend: function () { $('#mainField').html('<img src="data/images/loader.gif" alt="Loading...">'); },success: function (msg) { alert(msg); closeEditor(); search(); } }); } function search() { $('#title').val($('#search').val()); $.get('engine.PHP?search=' + $('#search').val(),function (data) { $('#mainField').html(data); }); $.get('engine.PHP?raw=true&search=' + $('#search').val(),function (data2) { $('#editorText').html(data2); }); $.get('engine.PHP?title=true&search=' + $('#search').val(),function (data2) { $('#h1').html(data2); // Row 152 $('#editorTitle').html(data2); }); } $(document).ready(function () { $("#ready").html('Document ready at ' + event.timeStamp); });
但是怎么了?