div onclick doesn't work for some reason - html

It's a very simple question and I'm amazed how is this not working for me, somehow this code:
<div id="logoutDiv" onClick="php_includes/logout.php"></div>
doesn't work, when I press on the div. What's the problem? I know that this is a very basic question, but somehow I've got stuck on it.

onclick is a JavaScript event. What you wrote is not JavaScript.
Maybe:
onclick="window.location.href='php_includes/logout.php';"

onClick only works with Javascript, not with links. Try this instead:
<div id="logoutDiv"></div>

Use window.location to call another page. <div id="myButton" onclick="window.location = 'php_includes/logout.php';">Page 2</div>

Related

button href is ignoring everything after question mark

I have this button
<button href="account.html?gto=4356">go to</button>
On click it redirects to ./account.html?# though i was expecting ./account.html?gto=4356.
Why is it ignoring everything after the question mark and how can I make this work?
Button tag does not support href attribute. instead use a tag and css design to make it look like a button.
go to
Hope it will help you.
You can do it with Javascript
<button onclick='goto()'>go to</button>
<script>
function goto(){
location.replace("account.html?gto=4356");
}
</script>
You Have to do it like this
<button>go to</button>
I hope this works for you! regards

Toggle multiple divs with classes

I need some help:
<button">Text</button>
<div class="show-on-button-click">Content</div>
<button">Text2</button>
<div class="show-on-button-click">Content2</div>
<button">Text3</button>
<div class="show-on-button-click">Content3</div>
I´de like to show content when the user clicks on the button. But it wont work, even all divs are shown, or it doesnt open and only the buttons are shown.
THX
You have to use some JavaScript/Jquery ;-
$(document).ready(function(){
$("button").click(function(){
$(".show-on-button-click").toggle();
});
});
Hope you solve it !!

Click on a link and go to another element on the same page

I have
<button> More </button>
and I have <div id="x"> </div>
But when I click on link, my page before going to desired div reloads(
I can't reproduce this behaviour on jsfiddle because there it works fine.
Can this be because I am using rails an turned turbolinks off?
If you need I can deploy the code to the server but I haven't done this yet.
Try to set data-turbolinks as false for that href tag.
data-turbolinks="false"
Trying this might solve the issue.

Data-bind for style not working in knockout js

myfiddle
style binding not works in knockout js. I dont know why its not working?
code :
<div class="sample" data-bind="style:{color:'blue'}">
hai
</div>
Please help me.
You forgot to call ko.applyBindings().
See fiddle

Make Disable-Enable Option with jQuery

i need some help to make a button for enable or disable 2 div with jquery. i have 2 kind of navigation code in my page. these are my codes:
First:
<div class="nextprev">
[prev-link]Previous[/prev-link]
[next-link]Next[/next-link]
</div>
Second:
<div id="page_navigation1" class="page_navigation1">[next-link]Next[/next-link]</div>
Now, i need some jquery code for enable or disable these div's. for example, when we click on enable button just first div will be working and when we click on disable, just second div will be working!
i hope u guys undrstand my question and im sorry for my bad english.
the toggle() function toggles the visibility of a div. so maybe something like this?
http://jsfiddle.net/UvWEu/17/
<script type="text/javascript">
function toggleDivs() {
$("#nav1").toggle();
$("#nav2").toggle();
}
</script>
<div id="nav1"
style="background-color:red;width:50px;height:50px;display:none;">nav1
</div>
<div id="nav2"
style="background-color:green;width:50px; height:50px;display:visible;">nav2
</div>
<button text="toggle" style="width:50px; height=18px" onclick="toggleDivs();" />​