-2

Experts

My requirement is to have a display the total registration lines on my jsp and a user can also edit those on click of an image next to it, To display the total registration lines Im using the following jpeg enter image description here Display a pencil next to the total using the code as

<div class="row-fluid" id ="result">
        <div class ="span2">
            <label><spring:message code='total.registration' />:</label>
        </div>
        <div class = "span3">
            ${registrationStatusForm.totalRegis}
            <img src="/static/img/icon_pensil.png">
        </div>
    </div>

and when a user clicks on the pencil next to the value displayed, an additional textbox should appear as below enter image description here On click of a pencil , a user should be able to edit the total and the icons are different as shown above.

on click of a X , the user should again see the 1st image.

Please suggest a suitable way to achieve this.

4

2 回答 2

2

您可以使用.toggle()

$('img').on('click', function(){
  $('your selector').toggle();
});
于 2013-07-16T18:45:08.643 回答
1

我会使用jquery。您可以简单地隐藏/显示元素

$('#element_id').show() 
$('#element_id').hide().

例如,如果你想在他们点击图片时显示一个新的 div,请监听点击事件:

$('#pencil_picture_id').click(function(){
  $('#text_box').show();
});

编辑:忘记括号

于 2013-07-16T18:37:14.037 回答