Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I need some help. See if you can help me out.
I have a function whose form is:
$this.find(settings.selector).each(function(index) {
Anyway, depending on a variable can change the selector as follows:
$this.each(function(index) {
Can you give me some idea how to do it? I hope I have explained roughly.
Thank you.
You can use a temp variable like
var $els;
if (some_condition) {
$els = $this.find(settings.selector)
} else {
$els = $this;
}
$els.each(function (index) {});
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I want to make subfunction like a.b.c(), I can't find name for this. Sorry for english.
What you are describing is just a function within an object, within another object, like so:
const a = {
b: {
c: () => "hello World",
},
};
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have this declared in my class:
somePair: KVPair;
Where KVPair is just a key value pair JSON.
Then in my displayFN I set it like so:
displayFn(pair: KVPair) {
this.somePair = pair;
}
But when I console.log(somePair) outside of displayFn, it's undefined, and I'm not sure why.
I was trying to set it with a [displayWith] which was clearing somePair.
When I set it in (optionSelected)="someFunction($event.option.value)", the value stuck around.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I know there are tonnes of answers to this question and all the answers are the same. I want to pass a variable to a selector. For example
var item = 'size_{{$item->size}}';
$("input[name="+item+"]").change(function () {
console.log('got it');
});
Let's say
{{$item->size}} == M // So the var item ='size_M'
This far the code is doing OK. There is no problem in item variable. But in the selector instead of getting size_M it's getting the item string itself.
actually i have to make this dynamic there may be lots of sizes like size_M,size_xxl, size_S and so on
in that case all you need is
https://api.jquery.com/attribute-starts-with-selector/
$( "input[name^='size_']" ).change(function () {
console.log('got it');
});
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I need to find an element that's text value is 0.
I do:
var d = $('.content').find('div');
if(d.text().length === 0){
//do something
}
Is there a way to put the above logic in the selector?
I've tried:
var d = $('.content').find('div:empty');
But no luck as the div may have other empty html tags in.
Use a filter
var elems = $('.content').find('div').filter(function() { return $(this).text() == 0 });
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am trying to figure out how the http://www.bitinstant.com page is made, especially how the listbox on the right is populated... and am a bit confused.
I know the listbox's name is "dest_exchange" but can't figure out where the data is coming from to populate the box.
Can you have a look and tell me where is the source URL/data please?
Dude, there's an event attached to the onchange() of select box: GetQuote();. And the function is defined in the same page:
function GetQuote() {
var $method = $('#pay_method').val();
var $amount = $('#amount').val();
var $exchange = $('#dest_exchange').val();
if ($method == "zipzap" || $method == 'fuze') {
$("#ofacbox").show();
} else {
$("#ofacbox").hide();
}
get_destaccount_tooltip($exchange);
$("#destaccount_label").html(get_destaccount_tooltip($exchange));
$("#payfromimg").attr("src","/static/images/logos/"+$method+"_carosel.png");
$("#paytoimg").attr("src","/static/images/logos/"+$exchange+"_carosel.png");
verifyMtGox();
if($amount.length==0) { return; }
Can't post the full code here, but it is from line 72 of the source of the page.