Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
sias1191357yvar setWebsite = prompt("What is your favorite website?");
var myFavorite = document.getElementById("favorite-website");
myFavorite.innerHTML = setWebsite;
this code prompts the user then is printed as text how would i refactor this code to print back as a link -
@sias11913 we'll need to see more, but you can try this example if it helps you out:
<!DOCTYPE html>
<html>
<body>
<script>
var response = prompt("what's your favorite website?");
document.body.innerHTML = '<a href="' + response + '" >Click here to go to your favorite website</a>';
</script>
</body>
</html> -
sias1191357y@sias11913 it’s for this coding challange n this part was a bonus I’m just trying to figure this all out
-
sias1191357yThe code works it prints back but the part I’m have trouble with is I need it to print out “find out and whatever url the user puts it redirects as a link
-
okkimus17187yHave you checked that your selector works? Console.log it and see if it returns the correct element.
I have sometime debugged code for like 45min and then realised that my selector was missin a dot or something.. :D -
sias1191357yI have tried it all all I want is to take what the user types and how using http:// it returns as a link
-
sias1191357yapp.setWebsite = function setWebsite() {
// code BELOW this line for challenge #3 & bonus -->
var setWebsite = prompt("What is your favorite website?");
var myFavorite = document.getElementById("favorite-website");
myFavorite.innerHTML = setWebsite; -
sias1191357ythe first part of this is right i got it to print back the url put the bonus part is printing it back with it saying find out here and as a link directing it to the users favorite website
-
okkimus17187yIt's quite hard to help you if you don't give us enough information...
Where is this challenge? Like some random website, CodeAcademy...link to it would be nice.
Share your code. Not just a tiny bit about it. Share some information. Paste it to codepen or somewhere as a whole.
Is there some other files aswell? I bet those 3 lines aren't the only ones doing something...
If you want to ask something, do it properly. Or go to StackOverflow. -
omom13597yStill need help? It's easy though people gave you many good ways to do it you just didn't take the time to try.
<a id="favorite-website"></a>
And in JS you also change the attribute href.
Document.getElementById(...).setAttribute ('href', url); -
Voxera113887y@sias11913 So you need to complement the assignment to innerhtml to create a link instead of just text.
Lookup the syntax for the <A href tag and just concat together a valid anchor element and your done. -
sias1191357yi do want the anwser but i want to an explantion how to do this as well ive already asked this on stackover no one knows this apparently
-
Voxera113887y@sias11913 You are demanding quite a lot since its a challenge you are supposed to do ;)
Maybe you should try to read a little and do some easier tutorials then. -
sias1191357yi thought it would be simple but it was to attempt to get into a coding school whats the point of this site if you cant learn
-
okkimus17187ySo you come to devRant to let someone else do your admission exercises for a $14 000 code bootcamp.
Just don't try to get there. Save 13k and do some online courses. -
omom13597y@sias11913 what you are asking for is very easy, and people gave you many answers, told you what to look for and where, and still you don't know how to get all this together.. @okkimus is right, go save some money and start by learning how to read some docs
-
It is a very easy task, and if you cannot solve it by yourself, you clearly don't deserve the bonus points. You are basically cheating on this assignment by asking others for help
i need some help with some javascript if anyone can please help
undefined
javascript