FAQ Database Discussion Community


Changing an attribute of a variable selector in Jquery?

javascript,jquery,variables,attributes,selector
I'm playing around with some Jquery as a hobby and I've run into a problem with changing the attribute of whatever the user clicks on. I have a bunch of tabs and didn't want to have create an event thingy for each of them, so I'm trying to put it...

Good practice on selecting a list menu

css,list,selector
Considering this markup: <div id="container"> <div id="mainmenu"> <ul> <li> <a href=""><h1>My Dashboard</h1></a></li><br> <li> <a href=""><h1>About</h1></a></li><br> <li> <a href=""><h1>Contact</h1></a></li><br> <li> <a href=""><h1>Setttings</h1></a></li><br> <li> <a href=""><h1>Log...

In jQuery, what does `this.selector` mean in `$(document).on('click', this.selector, …)`?

javascript,jquery,dom,selector
In a jQuery plugin I saw expression like this: $( document ).on( 'click', this.selector, this.startImageLightbox); I know what $("div").click(callback) mean, but the whole expression above, especially this.selector looks quite confusing to me. What does the this here mean? Does anyone have ideas about this?...

How to use ImageButton state_focused?

android,selector,imagebutton
my xml file <LinearLayout android:id="@+id/fragmentSelectorArea" android:layout_width="fill_parent" android:layout_height="@dimen/main_seletor_height" android:layout_marginBottom="@dimen/main_seletor_margin_bottom" android:background="@color/mainBtnBg" > <ImageButton android:id="@+id/myBtn" android:layout_width="0dp" android:layout_height="@dimen/main_btn_height" android:layout_weight="1" android:background="@drawable/btn_selector" /> </LinearyLayout> btn_selector.xml <item...

Javascript array to point variable name with similar function

javascript,arrays,function,selector
I'm want to shorten this function with array document.mySchedule.breakfast.onchange = function() { var id = document.mySchedule.breakfast.selectedIndex; var val = document.mySchedule.breakfast[id].value; strUser[0]=val; } document.mySchedule.lunch.onchange = function() { var id = document.mySchedule.lunch.selectedIndex; var val = document.mySchedule.lunch[id].value; strUser[1]=val; } document.mySchedule.dinner.onchange = function() { var id = document.mySchedule.dinner.selectedIndex; var val = document.mySchedule.dinner[id].value;...

jQuery How to add/remove dynamically created elements from dynamically created divs?

jquery,dynamic,selector
I am attempting to make a form that has 3 fields. It also has buttons to add another set of fields called modules. This part works. Each module that is created, should then be able to create more sets of fields below them called tasks. The hierarchy goes: Project: Module:...

Views not being removed from Superview when Selector method called

ios,objective-c,selector,uibarbuttonitem,uitoolbar
For my app, I have a UIToolBar that appears above a UIWebView. What I'm attempting to do is remove both the tool-bar and the web-view from the superview when UIBarButtonItem in the tool-bar is clicked. I've made the tool-bar and web-view properties of my ViewController like so: @property (nonatomic, weak)...

jQuery: Ignore class in selector

javascript,jquery,selector
What I have is a div and inside that div various elements. Now I wan't to add a click event to the div, but don't add it to elements inside the div with a certain class. The thing is, the elements can be on different levels which I don't know,...

Function for UIBarButtonItem

ios,xcode,swift,selector
I'm using Core Data and I'm making a save button with this code: self.navigationItem.setRightBarButtonItem(UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: Selector("saveTapped")), animated: true) The save function: func saveTapped(){ if (cell!.textField.text.isEmpty) { let alert = UIAlertView() alert.title = "Nevyplnené údaje" alert.message = "Musíš vyplniť všetky údaje o knihe." alert.addButtonWithTitle("Ok") alert.show() } let appDel:...

scrapy selector xpath extract matching regex or slicing string

python,regex,xpath,scrapy,selector
I am a newbie in scrapy and a bit on Python. I want to retrieve item['rating']. The rating is in a form of a string "rating is 4" but I want only the number... How can I get it? I tought about these to solutions below, but dont know if...

jquery select div inside parent of calling element [closed]

jquery,selector
For the past several hours i am trying to set the display of a hidden div to visible but i can't reach that div with jquery. After clicking the button i pass the value to a function. from there i want to set a hidden div visible which is inside...

Python: Scrapy spider doesn't return results?

python,parsing,csv,scrapy,selector
I know I need to work on my selectors in order to tune in on more specific data, but I don't know why my csv is EMPTY. my parse class: class MySpider(BaseSpider): name = "wikipedia" allowed_domains = ["en.wikipedia.org/"] start_urls = ["http://en.wikipedia.org/wiki/2014_in_film"] def parse(self, response): hxs = HtmlXPathSelector(response) titles = hxs.select('//table[@class="wikitable...

What does the $ sign mean in css and how validate it?

css,selector
in one of my css code I saw this code: .\37 u, .\37 u\24 { width: 58.3333333333%; clear: none; margin-left: 0; } I try convert it ... .7u, .7u$ { width: 58.3333333333%; clear: none; margin-left: 0; } Now I try validate it...so I add 'i' before number....but what is '$'...

Displaying a row selector (cursor / pointer) in a JTable

java,swing,jtable,cursor,selector
I'm migrating an MS-Access app to Java. My concern is about data grids. My first one is ok (JTable in a JScrollPane), but lacks the row selector (cursor) that you can see in MS-Access grids or OpenOffice Base grids. By "row selector", I mean the little black arrow at the...

Pan gesture recognizer selector won't work

ios,swift,sprite-kit,selector
In a SpriteKit game, I am trying to create a UIPanGestureRecognizer without using Interface Builder, so in the didMoveToView method of my SKScene, I wrote this : let panGestureRecogniser = UIPanGestureRecognizer(target: view, action: "didPan:") view.addGestureRecognizer(panGestureRecogniser) Still in my SKScene class, I wrote this function : func didPan(sender:UIGestureRecognizer) { println("Panned") }...

I would like to make a button selected using selector item with shape in android

android,selector,shape
I have defined button style using selector with shape and kept the same in the drawable folder. Then attached it with the buttons in a layout file. The button background color has been changed on pressing a button, but default color is showing after releasing the button. What I want...

Get exact selector in jQuery / alternative to .selector

jquery,selector
I wish I could write something like this $("div.banana .for aside.scale").yellowify(); $.fn.yellowify = function () { this.css("color","yellow"); alert($(this).selector); }); which would alert div.banana .for aside.scale The question is very similar to this one, however, there the poster wants to retrieve a DOM structure by scanning parents of the selector or...

JMS selector strange behaviour

java,queue,jms,selector
In JMS consider the following pseudo-code: Sender: QueueSender qs = session.createSender(queue); int i = 0; while(i < 10) { TextMessage msg = session.createTextMessage(); msg.setText(""+i); msg.setIntProperty("value", i); qs.send(msg); i++; } Receiver: String sel = "value >2"; QueueReceiver qr = session.createReceiver(q,sel); while(true) { TextMessage tm = (TextMessage) qr.receive(); System.out.println(tm.getText); } I would...

jQuery Selecting one of multiple elements with the same class

jquery,class,if-statement,selector
Trying to write a simple script that will change the background color of an element with a certain class (.global__image-outer-wrap--game-medium) if an "a" within another class and also parent of both (.giveaway__row-outer-wrap) has a certain class (giveaway__column--group) in case when there's multiple elements with (.giveaway__row-outer-wrap). if ( $(".giveaway__row-outer-wrap,a").hasClass("giveaway__column--group") ){ $(.global__image-outer-wrap--game-medium").css("background-color",...

CSS Target Attribute Containing Partial Match

html,css,match,selector,partial
Using the following CSS, why am I not able to target the 3 following anchor tags? a[href~="checkout"] { /* Do something. */ } <a href="http://shop.mydomain.com/checkout/onepage/"> <a href="https://shop.mydomain.com/checkout/onepage/"> <a href="https://shop.mydomain.com/checkout/onepage/?___SID=S"> What am I doing wrong in my CSS selector? I'm trying to select a partial match using ~= for all URLs...

save selection in session and show in table

php,html,session,selector
I have a selector that selects all the data from my database. <?php $results = $database->Selector(); ?> <form name='form' method='POST' id='selector'> <select name='train_id[]' id='train_name' multiple='multiple'> <?php foreach($results as $train_details){ //Look through every result in DB echo "<option value=" . $train_details['train_id'] . ">" . $train_details['train_name'] . "</option>"; } ?> </select><br />...

HTML parsing unknown selector needed

html,css,parsing,jsoup,selector
Using Jsoup an html parsing java library, i have located this from a website: <div class="jobCardListingTitle"> <a href="/jobs/hospitality-tourism/other/listing-846200105.htm" id="ListView_CardRepeater_ctl02_card_JobCard_JobCardTitleLink">Cafe staff wanted!</a> using: Elements Jobs = doc.select("div.jobCardListingTitle a"); however i want to retrieve "cafe staff wanted" but i only know how to retrieve href System.out.println(Job.attr("href")); and id... System.out.println(Job.attr("id")); How do i...

How to get a selector of a class method?

ios,objective-c,osx,selector,objective-c-runtime
I have the next code where I am getting a pointer to instance method: #import <Foundation/Foundation.h> #import <objc/runtime.h> @interface TestClass : NSObject @end @implementation TestClass - (void)someMethod { // This is instance method, it's okay NSLog(@"Hello from some method!"); } @end int main(int argc, const char * argv[]) { typedef...

How do I select a class but not its inside element?

javascript,jquery,jquery-selectors,selector
Say I have <div id="mydiv"> <div class="myclass"> <span class="otherclass"></span> and many other classes... </div> </div> I want to capture the click event on .mydiv but not inside .myclass. I tried .mydiv:not(.myclass) but it doesn't seem to work. I think it's because I might be clicking on the otherclass so the...

Using $(this) at a method inside another method in jQuery

javascript,jquery,this,each,selector
So, I'm trying to use the 'this' selector in a method inside another method, example: $('form').submit(function(event){ $('input').each(function(){ if($(this).val().length < 2){ $(this).addClass('error'); event.preventDefault(); } }); }); When I made that, I thought it would admit 'this' as each input, but no, the 'this' selector are associated to the form. I know...

CSS :not selector not working as intended

html,css,list,selector
I am trying to use the CSS :not selector to select all list elements that do not contain a link. Even though the first element contains a link, for some reason it is still following the CSS rules of the :not selector. Here is the example on CSSDesk: http://www.cssdesk.com/bFrgz Here...

javascript selectors document.object

javascript,selector
I am trying to select few elements into my html page and I'm wondering why I should use all the time that "document" when I'm targeting html elements for example: //variable body var content = document.getElementsByTagName("body"); in next variable why I cannot use something like: get all p tags from...

Use dropdown list selection to populate second dropdown list contents

javascript,jquery,drop-down-menu,selector,taffydb
The code below populates the first dropdown with distinct pants brands: $.each(pantsBrands, function(i){ var li = $('<li>') .appendTo(pantsList); var aaa = $('<a>') .text(pantsBrands[i]) .attr('onclick','askPantStyle()') .appendTo(li); }); In this next bit of code, I intend to somehow use the selection above to populate the contents in a second dropdown box composed...

How do I pass a parameter in a action:@selector? [duplicate]

objective-c,selector
This question already has an answer here: Can't pass arguments into @selector methods? 2 answers I am trying to pass a NSString parameter through action:@selector. I have tried many things such as action:@selector(function:example) action:@selector(function:example) action:@selector(function) withObject:example None of these are working for me and I have no Idea what...

App crashes when passing an argument to a method in NSTimer

ios,objective-c,selector,nstimer,unrecognized-selector
I'm trying to create an NSTimer where I can pass different UILabels inside of it that will change text color depending on the time. Here's a sample of the code I'm using in hopes of achieving that. I was sure it would work, but as soon as the timer starts...

jQuery: are these all statements true for find() method?

javascript,jquery,find,selector,chaining
I'm curious if all the statements below are equivalent: $(".postcell div").find(".post-taglist") $(".postcell").find("div").find(".post-taglist") $(".postcell").find("div .post-taglist") and if it is valid for any number of .find in chain, any classess, ids etc. The reason I ask is to be sure I don't miss anything when I replace selector with (variable + the...

Swizzling - Undo method selector swizzling in Objective-C iOS

ios,objective-c,uikit,selector,swizzling
We're making use of Swizzling in Objective-C. For convenience we're using CoconutKit's helper methods to achieve this: HLSSwizzleSelectorWithBlock_Begin([TMObjectCache class], @selector(objectForKey:)) ^(TMObjectCache *self, NSString *key) { key = nil; return ((id (*)(id, SEL, NSString*))_imp)(self, _cmd, key); } HLSSwizzleSelectorWithBlock_End; We'd like to however also un-swizzle this method after some point in the...

Union between two jquery selectors

jquery,jquery-selectors,selector
This is my case: var elems = form.find(':input'); var clEditors = form.find('.cleditor').parent(); elems.css('border', '2px'); clEditors.css('border', '2px'); Is there anyway I could prevent the duplication and do something like this: var elems = form.find(':input').union(form.find('.cleditor').parent()); elems.css('border', '2px'); I tried using a multi selector with the :parent selector and it didn't work: var...

Android: How to change the color of the dateselector in Datepicker widget?

android,colors,datepicker,calendar,selector
this is my first time posting a question. I've successfully implemented a Datepicker in my app (targeting only SDK 21 and above). I also want to style my Datepicker to blend with the rest of the app. This is what I have: <style name="MyDatePickerDialogTheme" parent="Theme.AppCompat.Light.Dialog"> <item name="android:datePickerStyle">@style/MyDatePickerStyle</item> <item name="android:colorAccent">@color/primDark</item> </style>...

Pressed state of android selector is not working

android,selector
I made android and arduino applications that control my standing desk. I upload this project on github(https://github.com/neosarchizo/MyStandingDesk) <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/down_button_pressed" android:state_pressed="true" /> <item android:drawable="@drawable/down_button" /> </selector> I wanted to use selector for buttons in MainActivity. If I press some button then an image of the button...

Button doesn't change its shape in selector

android,xml,button,selector,shape
I'm trying customize outlook of my button. The problem is, that button doesn't want to change its shape. That mean it's still sharp instead oval. button_selector.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@color/green_bright"> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <corners android:radius="8dp"/> <stroke android:color="@color/green_primary"/>...

iOS: Unrecognized selector sent to instance

ios,selector
I have a class where I request information from a provider class, in which after finalizing the job (asynchronous httpRequest block) needs to invoke a method [- (void) updateCountries] in the requester class. If I am not wrong this code worked in iOS 7, but now in iOS 8 it...

Select element with double dot in id, error: “#octo:cat” is not a valid selector

javascript,d3.js,selector
Given an svg with an existing id="kvg:StrokeNumbers_07425", <g id="kvg:StrokeNumbers_07425" style="font-size:8;fill:blue;">...</g> I do the following : d3.select("#kvg:StrokeNumbers_07425").attr("style","fill:red;"); and get the following error message : Uncaught SyntaxError: Failed to execute 'querySelector' on 'Document': '#kvg:StrokeNumbers_07425' is not a valid selector. It's likely due to the :. What should I do to make it...

unrecognized selector isPitched called

ios,objective-c,mapkit,selector
In my app, I am displaying a map with annotations, and the user can browse the list of annotations in a table view (in a modal view controller). I am experiencing a weird bug that I can reproduce both on device and in the simulator (iOS 7 & 8). When...

How to add a class via jQuery where the class has no name

jquery,selector,addclass
In jQuery, how do I select and add a class to a class when the class does not have a value? Here is some example code: <div class=""> <div class=""> <span class=""><i class=""></i></span> <div class=""> <span class=""></span> <span class=""></span> </div><!-- /.info-box-content --> </div><!-- /.info-box --> </div> If I only have...

jquery how do i reach element id when element is stored in variable

jquery,selector
is it possible to get element id when element is stored in variable? var element = $("#someElement") var id = element.id(); if i have something like that its not working. Element is also only stored in variable, not in DOM right now. ...

NSTimer firing more than it should

ios,objective-c,selector,nstimer
I do understand that it's my problem but not the problem of NSTimer but I would be really grateful if anyone could help me. In my project I need to call this method every 0.5 seconds for 2 objects. The problem is that the timer fires at different moments of...

Combo Box Internal Link Selector HTML

html,hyperlink,combobox,selector,internal
I'm trying to include a combo box on my websites homepage, that will jump to specific internal links when the correct value is selected. I have this test code so far but I haven't managed to strike any luck! Could anyone let me know where I am going wrong? Many...

Find nth element by classname using selenium python

python,ajax,angularjs,selenium,selector
I just started using selenium yesterday to help scrape some data and I'm having a difficult time wrapping my head around the selector engine. I know lxml, BeautifulSoup, jQuery and Sizzle have similar engines. But what I'm trying to do is: Wait 10 seconds for page to completely load Make...

How to pass arguments to the selector in NSNotificationCenter?

ios,swift,selector,nsnotificationcenter
This code checks when the app becomes active and runs a specific method dataMain(). I added a argument to dataMain(productCode: String). NSNotificationCenter.defaultCenter().addObserver( self, selector: "dataMain", name: UIApplicationDidBecomeActiveNotification, object: nil) Is there any way I can pass the productCode argument to the selector?...

Android selector not working in custom view

android,selector,android-custom-view
I have the following simple selector: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/main_menu_button_background_pressed" android:state_pressed="true" /> <item android:drawable="@drawable/main_menu_button_background" /> </selector> and the following activity's xml: <LinearLayout android:layout_width="0dp" android:layout_height="match_parent" android:orientation="vertical" android:background="#FF0000" android:weightSum="2"> <Button...

How to load data into variable instead selector in jQuery?

jquery,variables,load,selector
I am having some trouble to load data from url with load method in jQuery into variable instead selector. So my code is this: $('#test').load('http://url #searchedID'); So this would load some string from url where html selector have id = searchedID e.g. "This is string" and then it would display...

set background image to a specified page with @page selector

php,html,pdf,selector,mpdf
i would to create a pdf file from html with mpdf library. i would to set a background image just to 2'nd page of rendered pdf(not all pages). i use the following code: $mpdf=new mPDF(''); $html = ' <body> <style> @page { background: url("../mpdf60/bg1.jpg") 50% 0 no-repeat; } </style> <div...

CSS Selector Equivalent Of jQuery.find in backbone.js?

javascript,jquery,backbone.js,selector
I have a Marionette view that has the following code: onRender: { $('#someDiv').find('a').click(function(){ // some code here }); } But I want to refactor to something like this: events: { 'click [selector here]': 'executeCode' }, executeCode: function() { // some code here } Is this possible?...

how to make item background and it's shape display together

android,selector,shape
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true"> <shape android:shape="oval"> <solid android:color="#996a151f" /> </shape> </item> <item android:drawable="@drawable/ic_temp_oval"> <shape android:cacheColorHint="@android:color/transparent" android:shape="oval"> <solid android:color="#00ffffff" /> <stroke android:width="1sp" android:color="#99a93435" />...

how to economize jquery selectors

javascript,jquery,this,selector
Probably a stupid question, but I couldn't find a direct answer, so how can I change ":not('#home div, .nav')" in to something like ":not('this div, .nav')"? That would allow me reuse the same function for different objects. $( "#home" ).click(function() { $("#content .plates").children(":not('#home div, .nav')" ).fadeOut(700); }); and here is...

Performance of jQuery selector

jquery,performance,selector
is this selector: $("div#myId") faster then this selector: $("#myId") ? Both works well, but i would like to improve the performance....

how can i use css selector to give style only to a first div between two divs of the same kind?

css,html5,selector
I want to give border to the first div with the class block in the code below: <div class="col-md-4 news"> <h3>News Feed</h3> <div class="block"> <p class="date"><span>15</span>march</p> <p><a href="#">serving people from 23 branches all over the nepal</a></p> <div class="clearfix"></div> </div> <div class="block"> <p class="date"><span>17</span>march</p> <p><a href="#">serving people from 23 branches all...

Confused on which selector should apply some css properties

css,list,selector
Have a simple question: properties like list-style-position should be added in ul selector, li or both?...

jQuery: selecting all elements having class X except those also having class Y [duplicate]

jquery,selector
This question already has an answer here: jQuery: select all elements of a given class, except for a particular Id 3 answers Is it possible in jQuery to select all elements having class X except those also having class Y? This is my code: jQuery( '.class_A, .class_B' ).mCustomScrollbar(); I'd...

get html form value using jquery through selectors [duplicate]

javascript,jquery,html,forms,selector
This question already has an answer here: Jquery get form field value 4 answers <form id="Task1_1_1"> Keywords: <input type="text" name="twitKey" value="iphone"><br><br> Coordinates: <input type="text" name="twitLoc" value=""><br> <br> Scope: <input type="text" name="scope" value="10" > km<br> <br> <button id="sendButton1_1_1">Search</button> </form> This is the form. I can get the values of the...

Swift default parameter & Selector Syntax

ios,swift,syntax,selector
I have a function that takes a default parameter: func myFunc(foo: Bool = true) { } I'm trying to figure out the correct Selector syntax for it as I'm adding it as a target for a UIRefreshControl self.refreshControl.addTarget(self, action: Selector("myFunc"), forControlEvents: UIControlEvents.ValueChanged) I have tried both Selector("myFunc") and Selector("myFunc:") -...

Selectors fail to translate properly from Chrome to Firefox and Safari

css,cross-browser,hover,selector,compatibility
Unabridged Explanation Last night I was working on replicating an interesting Codepen I found. After I finished it, I was extremely happy with how it worked. Since I wasn't planning on using it in production, I neglected to use the proper CSS prefixes to insure cross-browser compatibility. However, when I...

CSS-only hover over thumbnail to display div

javascript,html,css,selector
I am attempting a simple way of using CSS only to display images within an element, when you hover over their corresponding thumbnail div. I thought this would be relatively easy using the tildie (~) to target the element outside of the thumbnail:hover scope, as both of them would be...

Jsoup Selector Regex matching

java,regex,jsoup,selector
I want to get just the elements with this id pattern "answer-[0-9]*" I'm using this regex in select "div[id~=answer-[0-9]*]" The matching elements are: <div class="post-text" id="answer-45881"> and <div class="hidden modal modal-flag" id="answer-flag-modal45881"> What must I change to get only the first one?...

Hover a div, affect another (CSS) [closed]

html,css,css3,hover,selector
I managed to affect one div by hovering over a different div using the "+" selector, which I would like to avoid. I would like this to work even if the .h div and the .t div were inside different parents. here is what i've got now: http://jsfiddle.net/FranLegon/y06gg3vt/ (it might...

Lua function selector

function,random,lua,selector
I have 3 functions. When the user presses the 'E' key I want it to select one of the functions (at random), I feel like it has something to do with math.random but I can't figure it out.

jQuery select or hide deeply nested div within a div with a class

jquery,nested,selector
I'm looking to hide a deeply nested div (with a class or ID name) within a container div with only class name. The container div is generated by an application so I cannot set an ID on it. I don't know exactly how many levels the div is generated so...

Insert element as second to last in JQuery

javascript,jquery,grid,selector
I have built a grid of elements using the Gridly library and want the last element to be a button that allows more to be added. Each time this button is clicked, it should add a new element as the second to last, where the button to add more remains...

Jquery selector not working with dynamic .get loaded content

jquery,html,jquery-selectors,selector
I have a page that dynamically loads content with a .get request from clicking a button. The HTML page that loads I can not get any jquery selector to target anything on that page. I tried putting the script for the alert on the page that gets loaded as well...