Is it possible to blur all elements of a form except for the submit button?

Can someone help me with a form issue I am facing?

<form>
<input type="text>'
<input type="submit">'
</form>''

After submitting the form, I would like to blur the entire form:

$(this).closest('form').css({
 'filter' : 'blur(1px)'
});

The problem is that this also blurs my submit button. Is there a way to exclude the submit button from being blurred?

Answer №1

To achieve this effect, you can blur all of the child elements within a form except for the submit button. This can be done using jQuery and attribute selectors or by applying specific class names. Here is an example implementation using class names:

HTML

<form id="myForm">
  <input type="text">
  <input type="submit" class="visible-on-blur">
</form>

Javascript (jQuery)

$('#myForm').submit(function( event ) {
  event.preventDefault();
  $(this).children(':not(.visible-on-blur)').css({
    'filter' : 'blur(1px)'
  });
});

You can also check out the demo on JSFiddle. https://jsfiddle.net/ajdyrvzq/4/

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

Exploring the power of JQuery.Each within a JavaScript module

Is there a way to dynamically insert the data-val of the anchor that was clicked within the scrollMove function using .each()? Currently, the code always inserts the data-val of the first anchor into the HTML. I want to achieve this with minimal JavaScript ...

Making an Ajax request to a RESTful web service from a different domain

Similar Question: Exploring methods to work around the same-origin policy I need to communicate with a RESTful web service from a different IP address using an AJAX request on my HTML page. Unfortunately, AJAX does not support cross-domain requests. ...

What is the best way to safely distribute the same npm package with multiple contributors?

Imagine a collaborative open source project with multiple contributors working on it. As the project progresses, these contributors need to publish their work to the NPM registry. But how can this be done securely when multiple people are involved? The ow ...

Type parameter in express.js route

If I have this specific route in my Express.js server: router.get('/ad/:id', (req, res) => { const { id } = req.params Ad.getAd(id, (err, resp) => { if(err){ return handleError('Failed to load an ad' ...

When using jQuery, PHP, and MySQL, newly added data will only appear on the page after it is

Looking to retrieve content associated with a marker on Google Maps and display it in a container? The issue arises when new content is added to the database, requiring a page reload for it to appear. Any suggestions on how to address this challenge? go ...

retrieve the value of a text form using jQuery and its corresponding id

I need help with a basic HTML form that includes jQuery. My goal is to: 1) Retrieve the value into a JavaScript variable. 2) Send it as JSON to a server. Here is the form: <div data-role="main" class="ui-content"> <data=role "form" ...

Clicking on the HTML dropdown triggers a jQuery/AJAX function that retrieves data from a

UPDATE: This question is quite complex and may not meet the expectations of those searching for an example related to (title). As a result, the OP has provided a simplified solution using jQuery to achieve (title). This answer is now marked as the selecte ...

Refresh the indicator upon data filtering via an ajax request

I'm encountering an issue where the location marker doesn't update when filtering. The old marker remains in place and new markers keep stacking on top of it. Even after using map.removeLayer(), the problem persists. If I use this function after ...

Choose an element that has been generated dynamically using jQuery

Here is an example HTML table to work with: <table id="#myTable"> <tr id="#row123"><td>Content</td></tr> </table> To insert a new row using jQuery, you can use the following code: $('#myTable').prepend(&ap ...

guide on implementing a horizontal scrolling/swipe navbar with Cordova

Currently, I am working on creating a "category list" with multiple items for a Cordova app. The initial approach was to use a simple HTML list, but unfortunately, it seems that my list is causing some unexpected behavior. Desired swipe navbar layout: ht ...

The Express API is failing to recognize the data keys that were sent from the React frontend, despite being clearly specified

I am facing an issue while trying to send data to a REST API using React hosted in a separate application. The API does not seem to receive the keys sent, even though I checked the results in Chrome and found this output:(2) ["imageSrc", File]0: "imageSrc" ...

Incorrect color change on button triggered by onMouse actions and state fluctuations

While creating a user profile on my app, I encountered an issue with button coloring. When I try to add color functionality to the button, it turns red instead of green and remains red even when the mouse is not hovering over it. My goal is to have the but ...

A valid path is required in the form of a string when working with the HTTP module in Node.js

Currently, I'm working on an update checker that doesn't involve downloading the update. My main goal is to compare the version in the package.json file on GitHub with the one in my Electron app. However, when using this code, I encountered a "p ...

Examining current elements in database using Node.js and MySQL

There appears to be a problem with the code inside con.query(query, function (err, result, fields). The issue is that it is never being called. This part of the code is meant to verify that when a user signs up, the email they enter is not already in use. ...

Hovering over an image and trying to rotate it results in

Check out my rotating image example on hover in React here This effect utilizes scale(), rotate(), and transition properties to create an animated rotation when hovering over the parent element. Additionally, overflow: hidden is applied to the parent elem ...

How can Angular CLI prevent the submission of an HTML form unless a previous option has been selected

I am currently working on a form that contains select fields with various options pre-populated. <form [formGroup]="selectVehicleForm"> <select formControlName="Manufacturer"> <option *ngFor='let ...

Guide on setting a property for req.session

I'm a beginner in node.js and sessions, and I am having trouble setting properties to the session! I am trying to add a property to the session and save it in the database, but I keep getting errors. Here are my codes: app.js (main js file) const s ...

"Modify hyperlink attributes to enhance security and optimize user experience

$("a[href*='youtube']").attr('rel', 'prettyPhoto'); Having some trouble targeting links on a page containing "youtube" in the URL. I'm trying to set their rel attribute to "prettyPhoto" so they open in a lightbox window. ...

Accessing Google Maps offline using HTML5 is a convenient and helpful

Our team is working on an HTML5 application that includes a Google map feature for changing search locations. Recently, we've added an offline version of the app as well. Is there a way to cache the Google map so that when the app is offline, it can s ...

Using jQuery to limit the number of lines in a paragraph and add three periods at the end for an

Hello everyone, I've been searching for a solution to my problem with no luck so far. Here's the code snippet I'm working with: <div id = "ta_0" style="display: none;"> <a href = "news.html">IRS announces 2011 COLA limits for ...