Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4020494
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:14:07+00:00 2026-05-20T10:14:07+00:00

I have the following jQuery that does find the ASP.NET server control (tested by

  • 0

I have the following jQuery that does find the ASP.NET server control (tested by placing an alert() inside block), but it does not set the height on the next DIV in the DOM using .next(). However if I use straight JS to do the same thing, calling the DIV by ID directly it works fine.

What I am trying to do is not use the hardcoded ID of the DIV in case it changes, and rather walk the DOM to dynamically get to the element and set the height.

So 1st: the HTML source of what I am trying to manipulate:

<div id="WebViewer" style="height:100%;width:100%;margin-right: 0px">
   <input name="WebViewerReportReceipt" type="hidden"/>
   <input name="WebViewerViewerType" type="hidden"/>
   <DIV id="WebViewer_controlDiv">
    <iframe src="295769102_1619997395_16141400_2120403583/CacheItem" style="width:100%;height:100%;"></iframe>
   </DIV>
</div>

Next the non-working jQuery that I think should work:

//Using the 'DIV' that is created by the viewer (at runtime), resize it dynamically to fit the window
    var myHeight = $(window).height();
    if ($('#<%=WebViewer.ClientID %>') != null) {                
          $('#<%=WebViewer.ClientID %>').next('div').height(myHeight - 10);
    }

And lastly the JS that does work, but I would prefer not to access that DIV by a hardcoded ID and use jQuery instead:

var myHeight = $(window).height();
//Using the 'DIV' that is created by the viewer (at runtime), resize it dynamically to fit the window
if (document.getElementById('WebViewer_controlDiv') != null) {
    document.getElementById('WebViewer_controlDiv').style.height = myHeight - 10;
}

Any ideas on why walking the DOM in jQuery to get the ‘next’ div and set its height is not working?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:14:08+00:00Added an answer on May 20, 2026 at 10:14 am

    I’m guessing that $('#<%=WebViewer.ClientID %>') in your if statement is referring to <div id="WebViewer" ?

    If so, next() will not work as it looks for the next sibling, not next child

    So try something like this:

    var myHeight = $(window).height();
    if ($('#<%=WebViewer.ClientID %> div:first').length) {                
          $('#<%=WebViewer.ClientID %> div:first').height(myHeight - 10);
    }
    

    Here is a jsfiddle with the running code (slightly modified to work in this context):
    http://jsfiddle.net/xT7rx/

    You should use .length to check if an element exists, rather than != null

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following JQuery code that worked perfect in C#/Asp.net 2.0 to call
Hallo, I have following jquery code for calling ASP.NET MVC controller method that is
I am begging to use jquery. I have the following call that works in
I have the following JQuery code which does similar functionality like Stackoverflow where the
i have the following jquery code. basically i will have several overlapped divs and
Let's say I have the following jQuery AJAX call: $.ajax({ type: POST, url: MyUrl,
Recently I have started playing with jQuery, and have been following a couple of
How do you rotate an image using jQuery-rotate plugin? I have tried the following
I have the following jQuery function: function GetGrandparentDiv(item) { return item.parents('div:eq(1)'); } Which is
I've got the following piece of Jquery: $(#collapse-menu > li > a).click(function() { $(this).toggleClass(expanded).toggleClass(collapsed).find(+

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.