Javascript innerHTML with form
Javascript innerHTML with form
我正在尝试在页面之间移动,但是当我尝试转到下一页时,它无法按预期工作。当我第一次单击它时,结果是 01 而不是 1,第二次它变成 011 而不是 2。我做错了什么?
HTML:
<p id='page'>0</p>
<div id='pics'>
<a href='<?=URL;?>index.php?p=gallery&image=<?=$pic['album_pic_id'];?>'>
<img class='<?php if($pic['album_pic_id'] == $image)
{ echo "selected_pic"; } ?>' width='90px' height='60px'
src='<?=URL;?>images/albums/<?=$pic['album_pic_photo'];?>' />
</a>
<a onclick='getElementById("page").value = getElementById("page").value+1;'>
Pievienot
</a>
</div>
Javascript:
window.onload = function() {
var page = 0;
};
使用 innerHTML
并将其内容解析为整数,parseInt
:
<a onclick='getElementById("page").innerHTML = parseInt(getElementById("page").innerHTML) + 1;'>Pievienot</a>
value
仅适用于form
元素,例如 input
。
相关文章:
- Fighting with FRP
- issue with FB.Event.subscribe
- Javascript innerHTML with form
- Bootstrap/jQuery form Validation with ASP.NET - 非常基本的功能
- JavaScript on JSP with Spring form:select
- Bootstrap Contact Form with jQuery Validation and AJAX
- JavaScript Form Calculation with Radio Buttons & Textbox
- PHP form with Javascript
- jquery remove() with multiple form
- PHP & HTML Form with javascript onsubmit not executed
- Run jquery ajax with multi diemnstion array without form
- how to send form value with "onClick="window.locat
- Summary of form in a <div> with jQuery
- Zend form setAttribs with json_encode
- Query Mean js with form,
- Form won't validate with an anchor section
- Form with Table,将所有值提交给IEnumerable Controller动作
- AJAX with javascript vs. Php Form
- Angular Form Submit built with ng-repeat
- Jquery load() + post form (with imagefield)?