Jquery was recently used in the project (my first time %)
It seems that its selector function is very powerful ~~~~~~~~
-----
I encountered such a requirement in the project:
Suppose there are several input types = "text" as follows ":
Code
Text with validate group property:
< Input Type = "Text" ID = "Validate1" Name = "Validate1" />
< BR />
Text withnot validate group property:
< Input Type = "Text" ID = "Validate2" Name = "Validate2" Validategroup = "B" />
If I want to obtain elements that do not include the validategroup attribute, how can I write the selector?
I wrote the following selector:
' Input [type = \ ' Text \ ' ]: Not ([validategroup]) '
After testing, we can only obtain the element without the validategroup attribute.
That's all right.
However, unfortunately, the recent popularity of "getting idle" also caught up with the trend:
I added the validategroup = "" attribute to the element id = "validate1", that is, validategroup with a null value:
Text with validate group property: < Input Type = "Text" ID = "Validate1" Name = "Validate1" Validategroup = "" />
At this time, I will use the same selector.
Result: I still got the same element. In principle, in that way, I got the element without the validategroup attribute?
But this element has attributes, but it only assigns null values ???
For custom attributes, what about native attributes?
This time I changed the id = "validate2" element and dried its ID into a null value:
< Input Type = "Text" ID = "" Name = "Validate2" Validategroup = "B" />
Then, I use the selector:
' Input [type = \ ' Text \ ' ]: Not ([ID]) '
After testing, the second element is obtained ..
So far, I come to a conclusion that I am not sure about myself:
When using: not to select a property, whether it is a native or custom property, as long as no attribute is written or the property value is empty, will it be seen as this property does not exist?
---
The egg is still hurting and the person is still idle:
I tested the general attribute selection:
HTML is:
Code
Text with validate group property:
< Input Type = "Text" ID = "Validate1" Name = "Validate1" Validategroup = "" />
Text withnot validate group property:
< Input Type = "Text" ID = "" Name = "Validate2" Validategroup = "B" />
The selector is:
' Input [type = \ ' Text \ ' ] [ID] '
The first element is obtained, that is, it is different from: Not at this time. For native attributes, as long as you write it, whether or not it is null or not, it will be considered to exist.
What about custom attributes? Change HTML:
Code
Text with validate group property:
< Input Type = "Text" ID = "Validate1" Name = "Validate1" Validategroup = "" />
Text withnot validate group property:
< Input Type = "Text" ID = "Validate2" Name = "Validate2" Validategroup = "B" />
The selector is:
' Input [type = \ ' Text \ ' ] [Validategroup] '
The result is: 2nd elements are obtained !!! That is to say, the attribute of the first element exists, but if the value is null, the selector will not want it !!!
Of course, if the attribute value is specified in the selector, for example, [validategroup = ''], you can get it.
-----------------------
It looks like not [ATT] and [ATT] are actually the same:
When determining whether a custom attribute exists, that is, when only: Not [ATT] or [ATT] is used, if this attribute is not written or the attribute value is blank, it will be regarded as not existent.
In this regard, for native attributes, only [ATT] is a little different: At this time, even if it is a null value, it will be found ..
Nothing else ..
The above is just a mess of me. I hope you can give me some advice !!!!