individual Div with ID not hiding through Jquery inside form tag

I have multiple divs inside a form tag.

<form id="RegdForm"> @Html.Partial("../Partials/_PatientEdit")

The partial view,

<div id="zafar"> <h3>Zafar</h3> </div>

When I try to hide all the divs its working like below

<script type="text/javascript"> $('Div').hide(); </script>

But when I try to hide specific Div it's not hiding at all.

<script type="text/javascript"> $('#zafar').hide(); </script>

I am using ASP.Net MVC 5 with Razor. Any help appreciated.

-------------Problems Reply------------

Try this

<title> Untitled </title>
<script src=""></script>
<style type="text/css">

<div id="zafar">
<div class="well well-sm">
<button class="btn btn-success" type="submit">Save</button>
<button class="btn btn-primary" type="button" data-bind="click: printPatient">Print</button>
<button class="btn btn-danger" type="button" data-bind="click: resetForm">Reset</button>
<button id="hide">Hide</button>
<button id="hideAll">Hide All</button>
<script type="text/javascript">



Here is your answer:

<script src="" type="text/javascript"></script>

<script type="text/javascript">

Add your respective function inside this.

$(function() {

After a long googling I found out one solution to this. As the div was inside the form tag, the way accesing the div can be done as,

<script type="text/javascript">
$('#RegdForm #zafar').hide();

It helped me to achieve the task.

Category:javascript Views:0 Time:2018-07-10

Related post

  • Why is an input tag not allowed directly within a form tag? 2011-03-25

    I just read the following at Non-block-level elements (such as <input>) are not valid directly inside <form> tags until HTML5. I had never heard of anything along these lines, and every basic HTML tutorial

  • event.pageX - Use JQuery Event in a function not bound through JQuery? 2009-06-11

    I have a table, and when the user clicks on each cell, some details should appear in a small popup div that appears where the user clicked. I'm using JQuery, but not to bind the function to the onclick event. function detailPopup(cell, event, groupNa

  • Div type="hidden" + Not hided 2009-06-12

    In my code. I m having Div tag with the type = "hidden". I just don't want to show the div. Only if needed I will make it to show by JQuery Show(). But still my div is not hidden from the view. Edit Now I make the DIV hidden by using <div style="v

  • X-Requested-With header not set in jquery ajaxForm plugin 2009-12-04

    I'm using the jQuery ajaxForms plugin to make an ajax submit to my CakePHP app. Cake's RequestHandler detects ajax requests by looking at the "X-Requested-With" header, but the forms plugin does not seem to set it. Or jQuery does not set it when usin

  • How to dynamically add attributes to mulitple div with same class name using jquery? 2011-08-05

    I have a "div" written in my html code like this <div class="mydata"> </div> and this is created dynamically when page renders so how many div with this same class name is going to be created is not fixed but using my code i can get the t

  • Hide Div with dynamic radio button using jQuery? 2012-04-02

    Fact: I'm not that good with jQuery. Problem: I have a form containing dynamically rendered radio buttons. When clicking on a radio button, I want a div to appear to give a text explanation. Within the "hidden" div I want a button or link to "close"

  • Dynamic show/hide div with javascript not working 2010-08-10

    I have a basic show/hide javascript that works, as long as i don't make it dynamic and make sure of a parameter. I would appreciate a lot if anyone could help me figure out why the dynamic version doesn't work. Working code: javascript function toggl

  • How to style an appended div with a click event? Jquery 2011-04-25

    Here is the function that works: /* $("#right-sidebar").click(function() { $(this).append("<div class='editable'>hello world</div>"); $(".editable").css("background-color","red"); }); */ It will append a div inside of the div with id "rig

  • Toggling multiple div classes based on visibility through JQuery 2011-12-28

    I'm trying to structure a group of links that will .fadeIn() <div>s based on which ones are clicked. I would like to .fadeOut() any <div>s that don't coincide with the current link that is clicked. I'm hoping it would also be possible to

  • How to show one of the many divs with the same id using jquery? 2012-04-06

    I am trying to use JQuery to show/hide one of the many divs with the same id on hover of one of the links that have a shared id. Markup Snippet <div id='menuOption'> <a href='#'><div id='cat_name'>$sub[cat_title]</div></a

  • Overflowing line of divs in div with scroll not new line 2012-03-12

    I have a div whith contains another divs with image. I need to have these divs in a on line but when I add another div whith don`t have enough place so this div go to a new line. Number of divs depend on number of images in db so I need scroll them.

  • Passing dynamic data to controller with ASP.NET MVC and jQuery on form submit 2010-07-19

    I have a website which is basically a single page containing a bunch of dynamic content. In normal operation the user should never leave this page. To handle/report certain errors though, I need to redirect to an error page. So on the error page I wa

  • Should jQuery's $(form).submit(); not trigger onSubmit within the form tag? 2009-03-14

    I have the following: <script type="text/javascript"> function CancelFormButton(button) { $(button.form).submit(); } </script> <form onsubmit="alert('here');"> <input type="button" value="Cancel" onClick="CancelFormButton(this);"

  • function not working for jquery load() content tags? 2011-08-05

    $(function(){ $(".tiptip").tipTip(); }); this tooltip function is working for all links.But it doesn't work for what are loaded through jquery load() function. I have experienced in live() function.I have used this function on content events(click,ch

  • do DIVs inside form tags cause problems? 2011-05-23

    It seems sometime to work fine and sometimes not, so in should I use divs inside form or not? and in general is there a guide for what HTML tags will not work inside other tags? --------------Solutions------------- Divs do not cause any intrinsic pro

  • Move all contrls inside form tag to div 2012-04-12

    This is the jQuery code that I am using to add the div to the page. var div = jQuery(document.createElement('div')); div.attr('id', 'divFormWrapper'); div.css({ "position": "absolute", "top": 0, "left": 0, "width": "100%", "height": "100%", "overflow

  • Use jquery inside html tag? 2012-03-24

    How can I insert jquery inside an html tag like using it in onclick. For example how can I insert this jquery function inside html? <html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/j

  • Hiding an error message div with setTimeout not working using Smarty 2011-01-07

    I'm trying to hide an error message div using a javascript function setTimeout after a specified time but it gives me errors that its a wrong smarty syntax, i've never used smarty before so i would really appreciate it if anyone can help me get up to

  • jQuery fadeIn when done loading each individual DIV with image? 2011-05-04

    I have a website that displays alot of pictures. Instead of showing them and watching it load, is there a way to fade it in after it's done loading? Kinda new to the wonderful world of jQuery and javascript. Right now I get data from a PHP file which

  • jQuery - Editing a newly created div with jEditable not working 2011-11-02

    I'm trying to create a frontend editor and I'm getting the data into a new div using an AJAX call, like this: function renderForm(type, position) { $.ajax({ type: 'POST', url: 'renderForm.php', data: "type="+type+"&position="+position, success: f

  • jQuery Accordion: divs with scrollbars not sliding nicely 2009-08-13

    I am using the following code to get an accordion happening: $(".accordion h2").eq(2).addClass("active"); $(".accordion-content").eq(2).show(); $(".accordion h2").click(function(){ $(this).next(".accordion-content").slideToggle("slow") .siblings("div

  • Contents of a Div formatting differently when built through jQuery 2010-07-09

    I have the following DOM structure: <div id="module-main"> <div id="module-crumbs"> <h4>Hello</h4> </div> </div> When I place that in a document and view it, it works fine. But if I build it from jQuery like so: $(

  • Flash player not hiding during jQuery toggle event 2011-01-24

    I am toggling show/hide using jQuery on a div block via $("#videoArea_" + id).fadeToggle(100); and it's working perfectly except for one minor detail. When there is a flash video player in that content area, the flash player will not hide along with

  • How to show a specific div with its own id in jQuery when I click a link? 2011-11-29

    I have a div like this: <article id="#pippo">blablabla</article> that I have hided with jQuery $('article').hide(); now I'd like to have a link menu that show a specific article id when it's clicked for example. If I click on link: <a

  • How to create array and divs with a unique height using jQuery? 2011-12-09

    I need 100 small divs for my chart, every time I generate them, I they all appear as the same height; the last value from the array. var valuesG = new Array(100); for (i = 0; i < valuesG.length; i++ ) { valuesG[i] = Math.floor(Math.random() * 101)

Copyright (C), All Rights Reserved.

processed in 0.094 (s). 11 q(s)