을 사용하여 특정 문자가 발생하기 전후의 모든 것을 제거하는 방법 그래서, 일부 HTML 코드를 가져 와서 입력 양식 아래에 표시하는 "사용자 정의"검색 막대가 있습니다. 들어오는 HTML이 양식에 있습니다JavaScript (html)
을 내가 입력 할 때 "바는"나는 검색 창에서이 결과를 얻을 :
그래서
는, 기본적으로 내가 켜려는를 "33 | balloon Rides Daily (1)"을 "Balloon Rides Daily"로 가져 가려면 어떻게해야합니까? 감사!
전체 코드 :
<form>
Search:
<input type="text" id="searchbar">
<br>
</form>
<div id="result"></div>
<script>
var term;
$('#searchbar')
.bind('keyup', function(e) {
term = $(this).val();
document.getElementById("result").innerHTML = "";
console.log(term);
getTags();
});
function getTags() {
$.get("myaspscript", {
needle: term
}, function(data, status) {
tags = data.split(", ");
$(result).html(data);
$($(result).find('ol').get().reverse()).each(function() {
$(this).replaceWith($('<ul>' + $(this).html() + '</ul>'))
})
});
}
</script>
</body>
편집 html로 보이는 방법
: 당신이 게시 할 수있는 경우 http://jsfiddle.net/gk2ud9fL/2/
내가 코드가없는 http://stackoverflow.com/questions/9932957/javascript-remove-character-from-a-string – tdmartin