I am trying to add the selected attribute to the option The tag using jQuery (those on a Wordpress site) those values that should be selected are stored in the PHP array. The selected attribute is & lt; Options & gt; .. ?
Why is not added to my-script.js each function ($) {var arr = [& lt ;? Php echo '' '.implode (' ", '', $ php_array)
jQuery (" # location options "). ''? & Gt;]; // for test Also the hardcode array is: // var arr = ["1", "2"]; if (jQuery.inArray ($ (this) .val (either)), ARM! = -1) {$ (this). Attr ('selected', 'selected');};}); .js The script is enqueqed properly.
< Strong> html-output
name = "location []" multi = "multiple" id = "location" class = "post-format" style = "display : None; "& gt; Option value =" - 1 "> Select a location gt; option class =" level-0 "value =" 1 "& gt; ; C Location A & lt; / option & gt; & lt; option class = "level-0" value = "2" & gt; Location B & lt; / option & gt; & lt; option class = "level-0" Value = "3" & gt; Location C & lt; / option & gt; & lt; / select & gt; The problem is that you remove every handler from $ and your code works fine: < Code> var arr = ["1", "2"]; JQuery ("# location options"). Each (function () {if (jQuery.inArray ($ (this) .val (), arr)! = -1) {$ (this) .prop ('selected', true);};});
Get link
Facebook
X
Pinterest
Email
Other Apps
Comments
Post a Comment
Popular posts from this blog
python - Writing Greek in matplotlib labels, titles -
-
June 15, 2015
I'm trying to write some text for labels, shape titles etc. with my plots, but no benefit till now Has not happened . I do not want to print specific characters (I know how to use special characters), I want to write the entire text in Greek (maybe Unicode and text ' ?). , suggesting that I would like to mention that for some reason I can not get matplotlib to cooperate with Tex (using IPython notebook from Anaconda in Ubuntu 14.10) so that there really is an option Will not be the first. I tried loading the Arial font and it loads successfully but again I get square blocks instead of characters. I import matplotlib.font_manager FM PROP = FM Font Properties (fname = '/ usr / share / fonts / truetype / msttcorefonts / Arial.ttf') And then to display the string I u'Î? ? I ?? Î¿Ï ?? ÎμÎ »second ?? μΠ± i ?? I ± i ?? I ?? Used ο किया? ? Î¿Î¼Î¿Î¯Ï ?? I ?? I · I ?? ' . Ariel is considered to be fully presented to Greek and I have used it many times ...
Read more
cmake set_source_files_properties not working properly -
-
April 15, 2015
I have a project in which. C is a group of files which need to be compiled as C files, but I need it to be compiled as C ++ code. I tried the solution I found, but did not work as expected. Instead of making filename.c only, it is compiled as C ++, it compiles all the files in my project as C ++ code. Without that call, all the files have been compiled as C. I also tried: set_source_files_properties ($ {FILES_SRC} property languages C) set_source_files_properties (filename.c property languages CFX) Where FILES_SRC variable keeps all my source files. I am CMK 2.8.12 and Visual Studio 11 ARM Generator. Any ideas how can I fix this? I finished compiling the library using C compiler and added a C ++ code to a different library For which I created a C interface so it can be told from my C library.
Read more
Pygame memory leak with transform.flip -
-
May 15, 2010
Today I came across an interesting issue which, by writing a small side scroller, instead of a sprite sheet, I was planning to use because I lacked a good "packer" for making phantom sheets (and honestly with patience and passion as it is only a test project). Anyway, I showed the animation running on the right of 8 PNG (with transparency). I considered it a good idea to prepare the flipped images to run on the left in the consultant, and the frame is not framed when the game is running (Flip actually consumes a lot of CPU like I Was measured). > To get access to the loop, I get the memory leak self.move_l = [# 8 PNG images with transparency to the right] For the self in IMG. Move_l: self.move_r.append (pygame.transform.flip (img, true, false) error traceback: traceback (most recent Call final): The file "D: \ Python 34 \ _Projects \ efg \ efg.py", in line 196, in the & lt; module & gt; main = master program ((1024, 680)) "D: \ Python ...
Read more
Powered by Blogger
Theme images by Michael Elkan
Szoka
Visit profile
Archive
September 2015673
August 2015642
July 2015638
June 2015645
May 2015677
April 2015654
March 2015625
February 2015643
January 2015611
September 2014679
August 2014584
July 2014593
June 2014626
May 2014616
April 2014658
March 2014597
February 2014650
January 2014649
September 2013677
August 2013624
July 2013646
June 2013659
May 2013660
April 2013653
March 2013632
February 2013706
January 2013605
September 2012628
August 2012648
July 2012657
June 2012618
May 2012636
April 2012655
March 2012674
February 2012613
January 2012608
September 2011580
August 2011569
July 2011646
June 2011642
May 2011638
April 2011655
March 2011661
February 2011653
January 2011640
September 2010666
August 2010665
July 2010667
June 2010649
May 2010605
April 2010659
March 2010633
February 2010594
January 2010616
Show more
Show less
Report Abuse