Use jQuery to remove tags and remove duplicates. jquerytag
Let's just look at the code.
Core code of the jsp page
<Head>
<Script type = "text/javascript" src = "js/jQuery. js"> </script> // jquery reference code
<Script type = "text/javascript" src = "js/delRepeat. js"> </script> // deduplicated js Code
</Head>
<Body>
<Input id = "repeatValue" type = "text" onblur = "delRepeat ()">
</Body>
DelRepeat. js
Function delRepeat (){
Var str = $ ('# repeatvalue'). val ();
Var strArr = str. split (""); // splits the string into an array by space.
Var uniqueArr = [];
$. Each (strArr, function (I, el ){
If ($. inArray (el, uniqueArr) ===-1) uniqueArr. push (el );
});
$ ('# Repeatvalue'). val (uniqueArr. join (""); // combine strings
}
Done!
Teach jquery: remove duplicates when adding drop-down menu options
Jquery's $. unique method is used to remove array duplicates. Here is a small example. How can we combine it with your instance?
Var arr = ['ason ', 'dremo', 'pobbe', 'eason'];
$. Unique (arr );
Alert (arr. join (","));
Jquery question: why does this website http: // www5icoolorg/tagphp? Tag = on the Right of jQuery, how does this effect be shared?
No, but I want to share it.
References: Fan