약간의 도움이 찾고 있습니다. 이 스크립트는 내 문제를 50 % 해결하는 스크립트를 발견했습니다. 단어를 클릭하고 아래 예와 비슷한 jquery를 사용하여 단어를 삭제하고 싶습니다. 아래 예제를 사용하면 클릭 한 단어가 강조 표시됩니다.Jquery and Regex와 (과) 같은 단어를 클릭하여 제거하십시오
<!DOCTYPE html>
<html>
<head>
<style>
p { color:blue; font-weight:bold; cursor:pointer; }
</style>
<script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script></head>
<body>
<p>
Once upon a time there was a man
who lived in a pizza parlor. This
man just loved pizza and ate it all
the time. He went on to be the
happiest man in the world. The end.
</p>
<script>
var words = $("p:first").text().split(" ");
var text = words.join("</span> <span>");
$("p:first").html("<span>" + text + "</span>");
$("span").click(function() {
$(this).css("background-color","yellow");
});
</script>
</body>
</html>
어떻게 단어를 삭제하고 삭제할 수 있습니까?
이 샘플은 단어를 단어로 바꿉니다.
var el = $('#id');
el.html(el.html().replace(/word/ig, ""));
내가 단어를 클릭하면 단어를 대체 할 수 있도록 나를 묶어 둘 수있는 사람이 있습니까? 그것은 어쩌면 단어를 [Delete]와 같은 것으로 대체 할 수 있으며 양식 제출시 정규식으로 제거 할 수 있습니까?
가 좋아 나는 종류의
$("span").click(function() {
$(this).css("background-color","yellow");
});
$("span").click(function() {
$(this).remove();
});
이 다음 질문으로 나를 불러옵니다 교체하여 알아 낸.
어떻게 결과를 양식 텍스트 필드로 업데이트 할 수 있습니까?
<form id="form1" name="form1" method="post" action="spin1.php">
<p><%=(Recordset1.Fields.Item("g_article_desc_spin").Value)%></p>
<textarea name="myfield" id="myfield" onFocus="this.blur();" cols="45" rows="5"></textarea>
<script>
var words = $("p:first").text().split(" ");
var text = words.join("</span> <span>");
$("p:first").html("<span>" + text + "</span>");
$("span").click(function() {
$('myfield').val($(this).remove().parent('p').text());
});
</script>
<input type="submit" name="button" id="button" value="Submit" />
</form>
아래 끝에서
업데이트 예를 나는 아직도 당신이 "양식 텍스트 필드에 결과를 업데이트"말할 때 myfield
감사 Carpie
편집 후자의 경우 아래에 의견을 참조하십시오. 아직 myfield를 업데이트하여 textarea의 텍스트를 업데이트하는 방법을 잘 모르겠습니다. 텍스트 영역에 onclick 이벤트를 넣어야합니까? –
당신이 제공 한 첫 번째 샘플을 체크하기 만하면 클릭 한 단어로 텍스트 필드가 업데이트되고 단락에서 단어가 제거됩니다. 그러나 두 번째 예에서는
태그의 단어는 제거하지만 양식의 텍스트 필드는 업데이트하지 않습니다. –죄송합니다. 나는 수술 문제가 있었다. 나는 그 부모를 얻기 전에 그 요소를 제거하고 있었다. 예제를 업데이트했습니다. 그게 효과가 있는지보십시오. – carpie