A text box will appear when you click on the edit button

When the edit button is clicked, I need to display text boxes and list boxes. Can someone please provide suggestions on how to accomplish this?

HTML:

<div class="textboxes">
<ul>
    <li><input type="text" id="txt" /></li>
    <li><input type="text" id="txt" /></li>
    <li><input type="text" id="txt" /></li>
</ul>
</div>

<input type="button" value="Edit" id="editBut" />

Javascript:

$("input[type='text']").blur(function(){
    $(this).hide().after('<span class="dfk">' + $(this).val() + '</span>');
});

Check out the js fiddle here: http://jsfiddle.net/thilakar/yvNuC/11/

Thank you!

Answer №1

Give this a shot

$("#editBut").on('click', function() {
 $('.textboxes span').hide();
 $('.textboxes input[type=text]').show();

});

Take a look at this DEMO

Answer №2

Check this out: http://jsfiddle.net/yvNuC/14/

$("#editBut").click(function() {
      if ($('.textboxes').is(':visible')) {
         $('.textboxes').hide();
         // perform save operation
         $(this).val('Edit');
     }
     else {
         $('.textboxes').show();
         $(this).val('Save');
     }        
});

Alternatively, if you want to display values after saving: http://jsfiddle.net/yvNuC/16/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating pathways in AJAX with Rails

Issue at hand: undefined variable article_id. The objective: Setting up the correct route for AJAX and Rails. What I require: The format articles/1/comments/2. Main goal: To specifically load comment through AJAX, not article. In the current AJAX scrip ...

Populate dropdown list dynamically in Codeigniter using AJAX and jQuery

Although this question may appear to be a duplicate, none of the other answers provided have solved my issue. My query pertains to populating a dropdown using ajax/jquery. While I can successfully send and receive data in JSON format, it doesn't seem ...

How to Retrieve the Parent ID in jQuery Sortable?

I'm currently experimenting with the sortable feature and encountering a minor roadblock. My aim is to extract the ID of the new parent element for use in an ajax request. UPDATE: I've managed to log the parent element, but it's duplicatin ...

Issue with Jquery's .change event not being activated

I'm having trouble with this script. I want to retrieve the selected value(s) from a multiple selection dropdown, but it doesn't seem to be working. Can anyone point out what's missing? Thank you! <script type="text/javascript" src="js/ ...

Combining both AJAX variables and HTML classes

Having trouble combining two AJAX variables with JQuery and PHP to add to a MySQL database... Here is the code snippet: $.ajax({ url: DIR+"some.php", method: "POST", dataType: "JSON", data: { mobile: mobile.val(), d ...

Introducing HTML elements into pre-existing web pages

My interest lies in the idea of injecting HTML into existing web pages for enhanced functionality. Specifically, I am exploring the concept of creating a more efficient bookmarking system. As someone new to web development, I am unsure of how to achieve th ...

implementing a fixed header in HTML

I am facing a challenge where I have a header with dynamic height and fixed position. My goal is to position the container div right below the header. However, since the header height varies, using a fixed value for margin-top is not feasible. Any sugges ...

I'm attempting to make it so that when users click on this link, it opens in a new tab instead of directing them away from my website. Unfortunately, using _blank

The link I have is currently opening in the same tab, but I want it to open in a new tab to keep users on my site. I've added target="_blank" to the code, but it's not working as expected. <BottomNavigation className={classes.root}> &l ...

What is the best way to incorporate several functions within a resize function?

Is it possible to incorporate multiple functions within the windows.width resize function? I have been experimenting with some code, but I would like to restrict its usage to tablet and mobile devices only, excluding laptops and PCs. Any suggestions on h ...

Having trouble getting Emberjs to properly handle an Ajax POST request

Currently, my goal is to send data to the database using Ajax POST. To start off, I have an HTML form as follows: <script type="text/x-handlebars" id="project"> <div class="row"> <div class="span6"> <form class ...

Dynamic jQuery Carousel

Is there a jQuery slider that can adapt to different screen sizes and handle images of varying widths? Appreciate any insights! ...

Angular: The Ultimate Guide to Reloading a Specific Section of HTML (Form/Div/Table)

On my create operation page, I have a form with two fields. When I reload the page using window.reload in code, I can see updates in the form. However, I want to trigger a refresh on the form by clicking a button. I need help writing a function that can r ...

What is the best way to create a divider between tab panes in JavaFX?

I created a unique vertical tabpane, but I am struggling to insert horizontal lines between each label. Below is the code snippet I have used: .tab *.tab-label { -fx-rotate: 90; } .tab { -fx-padding: 3em 0.5em; } .tab-pane .tab-header-area .tab ...

Scroll Bar Menu (User-Controlled)

I'm looking for any libraries out there that can replicate or provide a similar horizontal scrolling menu to that of espn.com's homepage. I'm relatively new to jquery and feeling a bit lost on where to begin. I did some searching on Google, ...

Enable user to reorder rows within a table and persist modifications to the database in ASP.NET MVC

I am working with a collection of photos that have an "Order" property. My client has requested the ability to rearrange the items and update the server with the changes. Can anyone provide guidance on how I can achieve this? Specifically, I am looking fo ...

Tips on positioning a button at the bottom of the screen in React Native

I am using the FAB component from the react native paper library. I want to align the button at the bottom, but it is overlapping with a text field. How can I position it below the text field? Please refer to the screenshot below: Here is the code snippet ...

How can I troubleshoot jQuery not functioning in iOS even though it works on Safari?

Trying to implement jQuery on a website using xCode simulator for testing, but experiencing issues. Works fine on Safari webkit though. Click here to view the site. I would appreciate finding out what's causing the problem, as well as advice on how t ...

How to Use jQuery to Validate an Empty Array Object in JSON

My array seemed a bit different. It was empty like this: {"18":[]} In contrast, other JSON objects appeared like this: { "223": [ { "virtuemart_state_id": "1", "state_n ...

Store the visible image location in memory to be used across various sections

I'm currently developing a website with a scrolling background image feature. However, whenever I navigate to another page on the site, the animation restarts from the beginning. Is there a way to cache the position so that the animation continues sea ...

Is there a way to apply padding to a div element that has a display property set to table-cell?

I am trying to achieve a design where I have an image and a div containing vertically centered text. The div should have padding around it along with a border, similar to this example: Currently, this is the closest I have come to replicating the desired ...