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 new to jQuery, so I'm having trouble solving this. I want this converted to jQuery.
JavaScript:
var el = document.getElementById("box");
el.style.backgroundColor = "#0000000";
var new_el = document.createElement("div");
new_el.innerHTML = "<p>some content</p>";
el.appendChild(new_el);
var $el = $('#box');
$el.css('background-color', '#000000');
$('<div><p>some content</p></div>').appendTo($el);
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 2 years ago.
Improve this question
In javascript if you have this by example:
const a = document.createElement("img");
a.src = "test.png";
document.getElementById("parent").appendChild(a);
Will this give true? -> document.getElementById("parent").hasChildNodes();
const a = document.createElement("img");
a.src = "https://www.gravatar.com/avatar/b4185aac47f6262b40dc8f11535a32c0?s=48&d=identicon&r=PG";
document.getElementById("parent").appendChild(a);
console.log(document.getElementById("parent").hasChildNodes());
<div id="parent"></div>
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 have a string
var str="[a54hy 8:45pm],[f57gh 9:20]"
i need to get
[f57gh 9:20pm]
I don't want to use split since the string length can be anything
This worked for me. where id is f57gh
var re='\\['+id + '([a-z0-9: ]+)\\]';
var rematch=RegExp(re,'g');
var mydata=str.match(rematch);
alert(mydata); //[f57gh 9:11am]
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 6 years ago.
Improve this question
Get Values from URL
var acutal_url = HTTP://my_host.com/account/apps/6/dashboard/6;
what i want is
var pattern_url = HTTP://my_host.com/account/apps/<int:app_id>/dashboard/<int:dash_id> ;
I want app_id & dash_id separately from this URL ..
Is it possible using JavaScript?
Try this
var acutal_url = "HTTP://my_host.com/account/apps/6/dashboard/6"
var app_id = acutal_url.substring( acutal_url.indexOf("/apps/") + 6, acutal_url.indexOf("/dashboard/") );
var dash_id = acutal_url.substring( acutal_url.indexOf("/dashboard/") + 11 );
alert(app_id);
alert(dash_id);
You should use regular expressions, but just in case you want a tool to do it for you, try http://txt2re.com/
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 have an html link like this:
<li id="schedule">
text
</li>
I would like to change the link (href attribute) that this anchor tag points to using javascript.
In my case, I would like to replace the value of the sku in the query string (ie replace '102333' with another number).
try this: http://jsfiddle.net/mig1098/ex6efsce/
var d = document.getElementById('schedule');
var chil = d.children[0];
var data = prompt('your data');
chil.setAttribute('href','/schedule?sku='+data);
alert(chil);
var url = chil.getAttribute('href');
var m = url.replace(/\/schedule\?sku\=/,'');
var r = document.getElementById('resp');
r.value = m;