[英]jQuery error text not appending
我有用於使用PHP和JS的簡單標記系統的代碼。 其后跟一個%
號,當我鍵入標簽時,接着是%
標簽,但是當我選擇它后,它會附加在文本區域中,例如,我鍵入%abc
,abc鏈接進入顯示框以選擇標簽,但是當我單擊它沒有任何反應。
<script type="text/javascript">
$(document).ready(function()
{## Heading ##
var start=/%/ig;
var word=/%(\w+)/ig;
$("#story").live("keyup",function()
{
var content=$(this).val();
var go= content.match(start);
var name= content.match(word);
var dataString = 'searchword='+ name;
if(go.length>0)
{
$("#msgbox").slideDown('show');
$("#display").slideUp('show');
$("#msgbox").html("Type the name of someone or something...");
if(name.length>0)
{
$.ajax({
type: "POST",
url: "boxsearch.php",
data: dataString,
cache: false,
success: function(html)
{
$("#msgbox").hide();
$("#display").html(html).show();
}
});
}
}
return false();
});
$(".addname").live("click",function()
{
var username=$(this).attr('title');
var old=$("#story").html();
var content=old.replace(,'');
$("#story").html(content);
var E="<a class='blue' contenteditable='false' href='#'>"+username+"</a>";
$("#story").append(E);
$("#display").hide();
$("#msgbox").hide();
$("#story").focus();
});
});
</script>
如果要在文本區域中顯示鏈接,則不能。
您應該為此使用DIV。
至於要發送到數據庫的數據,您總是可以將DIV的內容放在變量中,然后通過ajax發送。
例如
<div id="data"><a href="textlink">testlink here</a></div>
在javascript中:
var contentData = $('#data').html();
通過AJAX將其作為屬性發送。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.