ASP.net Step Through/ Line break in Javascript

Murray Brown
Murray Brown used Ask the Experts™
on
Hi. I am fairly new to JavaScript. How do I step through JavaScript and put line breaks in.
My code resides in an ASP.net VB.net web app

<script type="text/javascript">
        //variable that will store the id of the last clicked row
        var previousRow;
        
        function ChangeRowColor(row)
        {
            //If last clicked row and the current clicked row are same
            if (previousRow == row)
                return;//do nothing
            //If there is row clicked earlier
            else if (previousRow != null)
                //change the color of the previous row back to white
                document.getElementById(previousRow).style.backgroundColor = "#ffffff";
            
            //change the color of the current row to light yellow
 
            document.getElementById(row).style.backgroundColor = "#ffffda";            
            //assign the current row id to the previous row id 
            //for next row to be clicked
            previousRow = row;
        }
     </script>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
NorieAnalyst Assistant

Commented:
Murray

Are you using Visual Studio or something else?
Murray BrownASP.net/VSTO Developer

Author

Commented:
Hi Norie, I am using Visual Studio 2017
Software Developer
Commented:
Try this

https://jsfiddle.net/tfuzwrk9/3/

<span  class="click" id="sp1">  Test for test </span><br>
<span  class="click" id="sp2">  Test for test </span><br>
<span  class="click" id="sp3">  Test for test </span><br>
<span  class="click" id="sp4">  Test for test </span><br>
<span  class="click" id="sp5">  Test for test </span><br>
<span  class="click" id="sp6">  Test for test </span><br>





<script type="text/javascript">

//variable that will store the id of the last clicked row
        var previousRow;


$(document).ready(function(){

	$(document).on('click', '.click', function(){
			 
  		var id= $(this).attr("id");
  
  		ChangeRowColor(id);
  });

});


        
        function ChangeRowColor(row)
        {
            //If last clicked row and the current clicked row are same
            if (previousRow == row)
                return;//do nothing
            //If there is row clicked earlier
            else if (previousRow != null)
                //change the color of the previous row back to white
                document.getElementById(previousRow).style.backgroundColor = "#ffffff";
            
            //change the color of the current row to light yellow
 
            document.getElementById(row).style.backgroundColor = "red";            
            //assign the current row id to the previous row id 
            //for next row to be clicked
            previousRow = row;
        }
     </script>

Open in new window

Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Obadiah ChristopherDeveloper User Interface
Commented:
A good choice would be to do it using the developer toolbar available in the popular web browsers Chrome, Firefox and IE. (F12 should bring it up)

If you still want it in ur vs code, put the keyword
debugger;

At the line u want to start debugging
Put a breakpoint in a line of javascript and run from vs studio in debug mode using IIS Express.
Murray BrownASP.net/VSTO Developer

Author

Commented:
Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial