jquery - javascript : apply plugin at once to all vs one by one -
I have a home page for 5-6 dynamically-generated jquery sliders inside the page.
& lt; Div id = "slider1" class = "slider" & gt; // Images here & lt; / Div & gt; & Lt; Div id = "slider2" square = "slider" & gt; // Images here & lt; / Div & gt; After all slider loaded at the end of the page after the slider plugin has been applied, $ ('# Slider1') applyplugin () .; $ ('# Slider2') applyplugin () .; ......... <.....
The question now is whether the plugin at once on all the sliders at the end of the page Should apply; Or i
below < Div id = "slider1" class = "slider" & gt; Sliders should apply one by one . I ...... images here ..... and lt; / Div & gt; $ ('# Slider1') applyplugin () .; & Lt; Div id = "slider2" square = "slider" & gt; ...... images here ..... and lt; / Div & gt; $ ('# Slider2') applyplugin () .;
Which would be better for the better user experience ? Or is there any other solution for this?
Edit: By mistake I wrote id = slider1
, its slider1, slider2 ...
Did you not really explain how you are trying to solve a "better user experience"? For example, do you show all the sliders at once? No slider is visible before a slider? No HTML has been displayed before the sliders? Etc. ...
Assume that .applyplugin ()
is written properly to handle more than one element at a time, so you can simplify your JavaScript You can:
$ ("# slider1, # slider2"). Applyplugin ();
Or use a common square name:
$ (".l slider"). Applyplugin (); Besides, I'm assuming that this is a typo in your question because you can not have two elements with the same ID.
If you want to ensure that elements are not shown until they are properly started, you can:
& lt; Div id = "slider1" class = "slider" style = "visibility: hidden;" & gt; ...... images here ..... and lt; / Div & gt; & Lt; Div id = "slider2" class = "slider" style = "visibility: hidden;" & Gt; ...... images here ..... and lt; / Div & gt; $ (". Slider") CSS ("Visibility", "Visible") Applicable plugin ();
If it does not address user experience, then you are trying to make better, please try to complete it.
Comments
Post a Comment