C # add and delete tags (select tag and style)

Source: Internet
Author: User

 

Function MarkSelectByID (a, B ){
Var m = document. getElementById ("tx_markname ");
Var num = 0;
If (num <= 3 & $ ("# lbl_MarkSelect" + B + "" ).css ("background-color") = "transparent") // no selection
{
If (m. value! = ""){
If (m. value. substr (m. value. length-1 )! = ""){
M. value + = "";
}
Var s = $ ("# tx_markname"). val (). split (""); // traverse the text box
If (s. length <4 ){
M. value + = a + "";
$ ("# Lbl_MarkSelect" + B + "" ).css ("background-color", "# f2eada ");
}
} Else {
M. value + = a + "";
$ ("# Lbl_MarkSelect" + B + "" ).css ("background-color", "# f2eada"); // set it to ivory after it is selected
}
Num + = 1;
}
// Select the selected tag and click "Remove style" again. The corresponding values in the text box are also removed.
Else {
// If no space is given at the end of the text box, a space is given by default.
If (m. value. substr (m. value. length-1 )! = ""){
M. value + = "";
}
$ ("# Lbl_MarkSelect" + B + "" ).css ("background-color", "transparent ");
M. value = m. value. replace (a + "","");
Num-= 1;
}
}

Var m; // The value when the three tags are saved to control the value exceeding the tag
// Method for changing the text box Value
Function MatkChange (){
Var g = $ ("# tx_markname"). val ();
// Clear the first space
If (g = ""){
$ ("# Tx_markname"). val ("");
}
// Two consecutive spaces are not allowed.
If (g. substr (g. length-) = "" & g. substr (g. length-) = ""){
$ ("# Tx_markname"). val (g. substr (0, g. length-1 ));
}
// Clear all styles
$ (". Cs_Mark"). each (function (){
Certificate (this).css ("background-color", "transparent ");
});
Var s = $ ("# tx_markname"). val (). split (""); // traverse the text box
Var num = s. length-1;
If (num = 3 ){
Var LastIndex = $ ("# tx_markname"). val (). lastIndexOf ("");
M = $ ("# tx_markname"). val (). substr (0, LastIndex + 1 );
$ ("# Tx_markname"). val (m );
}
If (num> 3 ){
$ ("# Tx_markname"). val (m );
}
Var j = $ ("# tx_markname"). val (). split ("");
$. Each (j, function (){
Var a = this; // each element in the text box
$ (". Cs_Mark"). each (function (){
If (a = this. text ){
Certificate (this).css ("background-color", "# f2eada ");
}
});
});
}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.