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
how do this in simple javascript without using JQuery?
I would like a simple way for execute this.
$('body').on('click','a[name=bt_del_dependent]',function(){
console.log('id:'+ this.id);
});
Thanks!
Delegated event handlers would look something like this
document.body.addEventListener('click', function(e) {
if (
e.target.tagName.toLowerCase() === 'a' &&
e.target.name === 'bt_del_dependent'
) {
console.log('id:'+ e.target.id);
}
}, false);
It's still not exactly the same, you'd have to check for closest match to the event.target, not just the event.target, and that would require writing a closest method as well
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 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 6 years ago.
Improve this question
Well, the title of question look like easy, and the solution is:
$('.weatherCity').each(function () {
if ($(this).text() == 'LONDON') {
$(this).text('London Weather');
}
});
but I working on Yahoo! Weather Plugin and want to change city name, it's not iframe and we allow to change style and etc.. but look like it won't let change any text in this plugin. I thought browser read my code then yahoo get the weathers then I used promise().done() but nothing changed.
jsFiddle
Thanks in advance
-jiff
As a work around for this problem, you can use like this,
var interval = setInterval(function() {
if ($('.weatherCity').length) {
$('.weatherCity').each(function() {
if ($(this).text().trim() == 'London') {
$(this).text('London Weather');
}
});
clearInterval(interval);
}
}, 100);
Fiddle
Constantly checks for the element using setInterval and stop checking once it is found.
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 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
How to check (.) fullstop in var javascript using onchange ?
EG: var xxx = 120.00;
What function that can check (.) fullstop in this var
I use to use isnan but not work ,
If i use on Event onkeypress , I can use keyCode for check.
But i want to use even onchange, Can i do that ?
IndexOf will find the first instance of a given character
if (theElement.value.indexOf(".") !== -1) {
// Yes, it has a dot
}
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) {});