0

Where can i find <button> tags?

Where can i find the tags like showTheText and the other ones? Example: <button type="button" onclick="showTheText();">text</button> <p id='text' style="display: none;">text</p> <script> var justavariable = 0; function showTheText() { if(justavariable == 0){ document.getElementById('text').style.display = 'block'; justavariable = 1; return; } if(justavariable == 1){ document.getElementById('text').style.display = 'none'; justavariable = 0; return; } } </script>

21st Dec 2016, 9:25 PM
Ammar Naif
Ammar Naif - avatar
6 Respuestas
+ 2
Greetings. I get the feeling that you are a man of action who copied this script somewhere else. The script you inserted is more than just a button and the button section has more than HTML in it. So this is probably easier than it seems at first. <button type="button" onclick="showTheText();">text</button> Try this instead: <button title="made by Dr.">Button Label</button> Cheers! Dr.
21st Dec 2016, 10:02 PM
Tristan McCullen
Tristan McCullen - avatar
+ 1
"i need a button that opens a webpage on-click" If you only need the button for that action ( and not show-hide an element ), the simpliest way is to implement the second model you've proposed: <a href="{link in here}"><button type="button">Text</button></a> So, no need of javascript ^^ You can delete all ( with the inner content ) the <script></script> tag... and replace your: <button type="button" onclick="showTheText();">text</button> by: <a href="http://my.website.com/my_page.html"><button type="button">Go to another page</button></a>
21st Dec 2016, 10:20 PM
visph
visph - avatar
0
If the question is to toggle visibility, jQuery has a toggle function. You can implement it yourself.
21st Dec 2016, 9:31 PM
Rishi Anand
Rishi Anand - avatar
0
I'm asking about the tags like showTheText so i can look for something like "Open url" between them i need a button that opens a webpage on-click
21st Dec 2016, 9:34 PM
Ammar Naif
Ammar Naif - avatar
0
Like this <button type="button" onclick="location.href='{link in here}'">Text</button> or this <a href="{link in here}"><button type="button">Text</button></a>
21st Dec 2016, 9:42 PM
Ammar Naif
Ammar Naif - avatar
0
Sorry, I'm not getting it Ammar. showTheText here is not a tag but a JS function that is called everytime you click on the button. And by your code, your showTheText function is actually going to toggle the visibility of text, clicking it once makes it disappear, clicking it again makes it reappear. jQuery consists of list of such functions, that you can easily implement in your project.
21st Dec 2016, 9:44 PM
Rishi Anand
Rishi Anand - avatar