1

I'm trying to call two different functions for two different HTML elements at the same time, but the second function isn't being read at all. I'm also trying to use the id to specify which corresponding elements to grab data from. Here's what I have:

function changeImage(id)
 {
  var s = document.getElementById('showcase');
  var simg = s.getElementsByTagName('img');
  var slen = simg.length;

  for(i=0; i < slen; i++)
  {
   simg[i].style.display = 'none';
  }
  $('#' + id).fadeIn('slow', 0);

  function createComment(jim)
 {
  //alert('hello?');
  var d = document.getElementById('description');
  var dh = document.getElementsByTagName('p');
  var dlen = dh.length;

  //alert(dh);

  for(i=0; i < dlen; i++)
  {
   alert(dh);
   dh[i].style.display = 'none';
  }
  $('#' + jim).fadeIn('slow', 0);

 }

1 Answer 1

2

It appears you are missing the closing bracket} at the end of your changeImage function.

Also you could shorten your script substantially using jQuery:

function changeImage(id)
 {
  $('#showcase img').hide();
  $('#' + id).fadeIn('slow');
 }
function createComment(jim)
 {
  $('#description p').hide();
  $('#' + jim).fadeIn('slow');
 }

Also, I'm not sure why you have a zero inside the fadeIn() function? If you want the img/p to show instantly, just use .show()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.