Is there a more efficient way to write this.
$('#test').find('option:selected[value!=""]')
You can configure it a bit, but using methods instead of Sizzle:
$('#test').find('option').filter(function() { return this.selected && this.value.length });
Benchmark : http://jsperf.com/sizzle-vs-methods-filter/12
.filter() for me, about 70%.
.filter()
Well, there will always be only one selected, therefore, in my opinion, you do not need a handler find().
find()
I just write like this:
$('#test option:selected[value!=""]')
I have not tested it yet.
Source: https://habr.com/ru/post/1790643/More articles:Unit testing approves duplication - unit-testingHow to change the value of a query string parameter using redirection? - redirectсериализовывать экземпляры scipy rv_continuous и rv_discrete подклассов - pythonHow to achieve true modularity of the application using Akka in OSGi packages? - scalaWaste Disposal in the Worst Case at Mono - performanceRounding in SQL Server - sql-serverWhat is a good sample program to demonstrate the incorrect handling of InterruptedException thrown by Thread.sleep ()? - javaCentering a div to the middle of a webpage? - htmlReading a text file in Qt - c ++обновление атрибута до нуля - rubyAll Articles