I want compare them(into tag <p>
) together if them are similar remove them, and show other word that not similar. but this code removed how are you?
beacuse think it is similar how
, what do i do?
Example: http://jsfiddle.net/CCMKu/
<span style="display: none;">
<p>hello</p>
<p>hi</p>
<p>how</p>
<p>what</p>
</span>
<div class="remove">
<p>hello</p>
<p>how</p>
<p>how are you?</p>
<p>what</p>
<p>fine</p>
<p>hi</p>
</div>
$("span p").each(function () {
$(".remove p:contains(" + $(this).text() + ")").remove();
});
Output is fine
in case output should be fine
$ how are you?
.
Updated the fiddle for you: http://jsfiddle.net/CCMKu/3/
var input = [];
/*
* Storing all values
* in a single array for
* a faster access
*/
$("span p").each(function () {
input.push($(this).text());
});
$(".remove p").each(function () {
var $this = $(this);
/*
* Now use the inArray utility
* function to find duplicates
*
* EDIT: Added toLowerCase() to allow
* case-insensitive matching
*/
if ($.inArray($this.text().toLowerCase(), input.toLowerCase()) !== -1) {
$this.remove();
}
});
try:
$("span p").each(function () {
var item=$(this).text();
$(".remove p").filter(function(){return $(this).text()==item}).remove();
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.