python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
jquery and MVC 4.

show hide div using Knockoutjs jquery in mvc 4

Hello everyone,

I'm going to share the code sample of show hide div (content menu) using Knockoutjs and jquery in mvc 4.

I have a requirement to show the div onMouseOver and hide the div onMouseOut in Knockoutjs application.

Table of contents

1. show the div on-mouse-over from div.
2. hide the div on-mouse-out from div.

Here have two steps.
1. In the Step-1, code sample for view.
2. In the Step-2, code smple for viewModel.

Step-1 :   view 
code sample

    <ul data-bind="foreach: mDateTime">
               <ul data-bind="foreach: $root.matter.index.type()[$data]">
                    <div id="hover" onmouseover="onMouseOver(this)" onmouseout="onMouseOut(this)">
                      <a href="#" ><img src="~/path.jpg" data-bind="text: matterId" /></a>
                        <div id="box" style="display: none">                       
                                <a href="#">Edit</a>
                                <a href="#">Copy</a>
                                <a href="#">Delete</a>
                <li data-bind="text: matterTitle"></li>
                <li data-bind="text: matterComment"></li>

Step-2 : jQuery code sample

<script type="text/javascript">
    //Show the div onmouseover.
    function onMouseOver(obj) {
        var currentDiv = obj;
        var divToShow = $(currentDiv).next("#box");

    //Hide to div onmouseout
    function onMouseOut(obj) {



Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - and
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like Powered by Blogger.
ASK Questions