0
<head>
<script src="jquery-latest.js" />

<script>
   function makeitnull(){
      alert('inside make it null');
      //using hex routine 1 -> 3 -> 5 -> 8 -> (11 == a)
      document.getElementById("u_0_1").value = "" ;
      document.getElementById("u_0_3").value = "" ;
      document.getElementById("u_0_5").value = "" ;
      document.getElementById("u_0_8").value = "" ;
      document.getElementById("u_0_a").value = "" ;
}
</script>

</head>

<body>

  <script>
    $( document ).ready(function() {
       alert('before make it null');
       makeitnull();
       alert('make it null pahse passed');
       $('#u_0_5').click (function(){
         $('#js_1').removeClass('hidden_elem');

      });

   });
</script>

The Problem is that the alert('make it null'); is working but after the function call rest of the code won't work. I am newbie to the web development on internet i tried to find out my problem but unbale to get the reasonable answer.

  • 2
    *rest of the code won't work.* doesn't mean anything, there are fundamental issues with your understanding of `jQuery` and `JavaScript` demonstrated in the code that make it impossible of anyone to *guess* as what *rest of the code won't work* means, it could literally be **anything and everything** you are getting wrong. The fact that you are using the term `null` and setting things to `""' which is `Empty String` and no where even close to be considered `null` demonstrates even more fundamental problems as well. You aren't going to get an answer without an viable question. –  Oct 18 '14 at 14:15
  • 2
    Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: [How to create a Minimal, Complete, and Verifiable example.](http://stackoverflow.com/help/mcve) –  Oct 18 '14 at 14:18
  • I said the code executes at the point of alert('before make it null'); and even the alert present inside the function makeitnull won't fires up – Dexter Abeer Oct 18 '14 at 16:01
  • All major browsers have incredible step debuggers in them for JavaScript today, that is what you need to use. –  Oct 18 '14 at 17:00

1 Answers1

2

As for "after the function call rest of the code won't work" that doesn't really mean anything useful.

That said ... read How to ask a good question if really want help them edit this question to fulfill the requirements in those instructions!

You should know that jQuery is JavaScript. Manipulating the DOM manually while using jQuery demonstrates you don't really understand what jQuery is for.

The title in this attempt at a question makes no logical sense, you can't "call JavaScript" from jQuery for the above reason. That is like asking "How do you do Algebra with Math?"

From the front page of the jQuery home page:

jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript.

You should not be traversing the DOM manually you should be using jQuery to look up things, that is what it was created for.

At no point should you have to resort to this:

document.getElementById("u_0_1").value = "" ;

this is what jQuery is supposed to be replacing

$("#u_0_1").value = "" ;

this kind of the entire point of JQuery!

You are already looking up other things with the correct syntax.

http://api.jquery.com/id-selector/

Community
  • 1
  • 1
  • Jarrod, you didn't really answer the main point to the question though. – Charles Oct 18 '14 at 14:12
  • there is **no main point of the question**, *rest of code won't work* is not a question by the definition of this site, or any other definition I know of, it is a *statement*. –  Oct 18 '14 at 14:16
  • I was looking at the code and besides the correction you made up top, shouldn't things still work? like the alert inside the function? – Charles Oct 18 '14 at 14:18
  • I don't know should they? We have no idea what those ids point to, what setting them to `""` might cause side effect wise or anything about "other code" that may or may not be correct. Learn to use `jsFiddle.net` if you want help. –  Oct 18 '14 at 14:19
  • K, cool. I was gonna create a fiddle for OP, but feeling lazy, I dont feel like doing anything, haha! – Charles Oct 18 '14 at 14:23
  • @DexterAbeer - you didn't read the help on **[How to ask a good question did you?](http://stackoverflow.com/help/how-to-ask)**, as is this doesn't fit any of the criteria of those guidelines, until you read that and try and implement those guidelines you are going to be frustrated with no one being able to help you. –  Oct 18 '14 at 17:02