Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to put a link on "one" in the following code
Javascript
function myFunction(){
document.getElementById("text").innerHTML="text set one";
I will have multiple of these functions with different text so I need to be able to pick out text and attach links (that will lead to pop-up windows).
EDIT: I need the click able one to have something like
`"MM_openBrWindow('index.html','New_Window','width=500,height=500')"`
Maybe this makes your job easier:
function myFunction () {
document.getElementById("text").innerHTML = "text set " + "one".link("#");
}
function myFunction () {
document.getElementById("text").innerHTML = "text set <a href='#'>one</a>";
}
You can inlude a in innerHTML.
function myFunction(){
document.getElementById("text").innerHTML="text set <a href='#'>one</a>";
}
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I am trying to make the contactform originally hidden when the page is loaded, so contactform is to be hidden originally to do this in CSS i did:
#contactform{
display: none;
}
now in the HTML I have:
<div class="contactme" >Message me!</div>
and onclicking the message me it calls the function 'someFunc' the function hides the contactinfo but displays the contactform, the function is:
function someFunc() {
document.getElementById('contactinfo').style.display='none';
document.getElementsByID('contactform').style.display='block';
}
It hides the contactinfo perfectly as expected, however it doesn't show the contactform. I believe this could be because the CSS is overriding the function, is there any way to stop it from doing so and get it working as expected?
There is bad function name, correctly is small "d" and "Element" instead of "Elements"
document.getElementById('contactform').style.display='block';
^ ^
in your code document.getElementsByID is mention not document.getElementById USE THIS code:
function someFunc() {
document.getElementById('contactinfo').style.display='none';
document.getElementById('contactform').style.display='block';
}
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 know this is probably a stupid question but unfortunately our programmer at work is sick today, of course my deadline is today... I seriously have no clue.
I have 2 divs: .translate_EN and .translate_NL
Well the problem is I need to show .translate_EN when my URL contains /en/ and show .translate_NL when my URL contains /nl/. It can also be selected by: www.domain.com/en/ and www.domain.com/nl/
You will help me ALOT if you can provide me this script!
Many thanks in advance!
This code will return '/en/' if url contains '/en/' or null if it doesn't.
window.location.href.match('/en/')
So you can write if block and make your div's property display block or none.
E.g.:
Make your divs style: display: none then on the page write that code inside <script> tag:
var isEn = window.location.href.match('/en/');
var makeVisible = function(className) {
document.getElementsByClassName(className).item().style.display = 'block';
}
if (isEn)
makeVisible('translate_EN');
else
makeVisible('translate_NL');
I don't know all your requirements but that code will help you to understand what you need to do.
If you have a jQuery on your page, then it can be done with that code:
$('.translate_' + window.location.href.match(/\/[a-z]{2}\//g).pop().replace(/\//g, '').toUpperCase()).show()
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
This is working fine for first element but not for the whole table.
how can i iterate this for whole table.
my jquery code is like this
$(document).ready(function () {
for (i = 0; i <= 42; i++) {
if (true) {
$('#mktType').addClass("important blue");
} else {
$('#mktType').addClass("important red");
}
}
});
What you are doing is a nonsense, you are adding the same classes 42 times to the element with id "mktType".
If you want to add classes to several elements according to a condition, you should :
Use a class selector instead.
Use each to apply a funciton to each element you selected.
Specify a real condition, use it only in loop if it depends on the element itself.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I would like to match this following condition using regex
<P ***anything here*** >
So essentially, I want to strip any opening P tag with any attributes. I dont want to stip anything else in the string.
Test case/
<p style='color: green;'>What a fine day it is</p>
Desired Result/
What a fine day it is</p>
As #kojiro already mentioned, this is not a good path, however:
var sample = "<p style='color:green;'>What a fine day it is</p>";
var result = sample.replace(/<p\b[^>]*>/ig,'');
// result = "What a fine day it is</p>"
Obligatory Footnote if you have an attribute that contains the > character within the <p> tag, this will fail epically. but, then again, that's why the above referenced post exists on SO. ;-)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to attach a listener to an element created via js dom manipulation. I thought that this is what jquery ON was for, but the below example is not working.
It works with the initial element, but not with any that are added via JS. The added elements have the correct class name.
<div id = "tag_options">
<div class = 'tag_option'>test</div>
</div>
function greet(event) { alert("Hello "); }
$("[class='tag_option']").on("click", {}, greet);
Try this:
function greet(event) { alert("Hello "); }
$("#tag_options").on("click", ".tag_option", greet);
Use delegation, e.g:
$(document.body).on("click","[class='tag_option']", greet);