JQuery (anti-) pattern: string selectors with string manipulations

Too often, I find myself building selectors with string manipulations (split, search, replace, concat, +, join).

Good or bad?

+5
source share
2 answers

What is wrong with that? What are the alternatives - just hard code them as single lines? But you can use the agreements on your site to organize the layout. If you simply define the components of the selector in one place and use it to create a selector, it sounds like it will be less of a hassle than looking at all the code and doing a search - replacing it wherever it appears.

, , ( , ).

+1

, :

, , - (: "div.product > span.price" ). , - . , .

, , , (: "input [value =" Login "]" ) ( ).

0

All Articles