Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. I think the functionality you're describing is an accordion menu. As for this: $('ul.nav').removeAttr('style'); I really doubt it's actually doing anything useful. You should look into addClass() and removeClass(). The way the code currently is, as soon as the window is wider than 600px the style attribute is removed, but you never put the style back, so it will stay like that even if you resize it back down to under 600px. You should have an else statement that does something else if the window is not wider than 600px. Another thing you probably would want to do is to have that same function run once as soon as the page has loaded. If you don't, then nothing will happen until the user resizes the window and they might not always do that.
  2. It's probably not giving an error, but I don't think it's doing anything at all. What did you intend when you wrote that code? If you explain your motives I can tell you what would be a better option. It would be ideal if I could see a working page. Check your browser's Javascript console in the developer tools and see what error messages you're getting. As for why your menu items are invisible, perhaps the text is the same color as the background. Check the styles you have applied to the elements.
  3. You don't really need to echo all those things out, just leave the HTML outside the <?php ?> block and it will be on the page automatically. Your code will be much more readable and you'll be saving the PHP engine a few instructions. I don't think that removing the style attribute from the element will remove the style property from the DOM. But what is the reason you're removing it in the first place?
  4. The <figure> element is part of HTML 5 and is used to contain images with an optional caption. Search engines can use it, for example, to determine the title and keywords that belong to the image. In order to get <figure> and other HTML 5 elements to work in older versions of Internet Explorer you need to use Javascript to tell the browser that those elements exist. Just writing document.createElement("figure") for each of the elements will work, then you need to give them their default styling with CSS. There are people who have built a Javascript program that does this for you, just search for "HTML5shiv". CSS 3 animations are supported by all modern browsers (with vendor prefixes), while older versions of Internet Explorer will not work. If it's not working in any browser for you then you have done something different from the instructions in the article, or perhaps you have not been updating your browsers. For the moment, it's probably best to use a Javascript image slider. One that will fall back to having all images visible if Javascript is disabled. There are still way too many people using old versions of Internet Explorer.
  5. This line is wrong: $( delete-row).remove(); What you're doing here is subtracting the numeric value of row from the numeric value of delete and then passing that to jQuery. Since row is not defined and delete is an operator, this is a syntax error. You usually pass strings to jQuery. But the string "delete-row" would not work either, because you have no <delete-row> elements on your page. jQuery uses CSS selectors, so if you're looking for a class name you need to prepend a dot "." to the selector, if you're looking for an id you need to prepend "#". There might be other mistakes in your code, so check the Javascript console in your browser's developer tools to see what the error messages say and what line their on.
  6. The best practice is to put all the code at the bottom of the page, including the jQuery library. The reason is simple: The jQuery library takes time to load, while it's loading the rest of the page is not loading. If the jQuery is at the top then the page will appear blank until the jQuery library loads. It might not seem like a big deal on a fast connection, but on slower connections it means a lot. Statistics indicate that if a person hasn't seen what they wanted on a page in seven seconds they'll leave the site, so having it load quickly is important.
  7. You should try running that Javascript after the page has finished loading. Be sure to check your browser's Javascript console for error messages. I imagine it says something like this: Unable to find property "click" on undefined.
  8. Many sites put scripts at the end of the body. There's a good reason for that. The onload event will not only wait for the content of the page to load, but all the images and videos, too. Your scripts might take a long time to begin running if you used the onload event. While a script file is loading everything else is halted. If you include scripts in the head then the page will be invisible until the script has finished loading and running. There's a better event than onload, the DOMContentLoaded event, but it cannot be used as an attribute, it must be passed as a parameter to addEventListener(). It also does not work in all browsers, you need to implement workarounds for older versions of Safari and Internet Explorer. jQuery's ready() method uses "DOMContentLoaded" internally, as well as workarounds for older browsers. But again, loading jQuery in the head of your document will slow down your page.
  9. Is the Javascript at the bottom of your page? Scripts need to be run after the element you're targeting has been loaded.
  10. Give a min-height to the box that's equal to the height of the image.
  11. You need one audio element for each new sound you want to play, just for convenience, because each <audio> element needs multiple children <source> elements with different file types. Each browser supports different file types, so you use the <source> elements to give multiple options. Creating all those elements dynamically with Javascript would be an unnecessary effort.
  12. There is no easy solution. You need to crop it in an image editing program. The image's width and height attributes should not have "px" in them, they can only contain digits.
  13. You can read about databases here: http://www.w3schools.com/php/php_mysql_intro.asp
  14. Which variable is not set? You never referred to it by its name. I think you might be referring to the "allDay" variable. In your code, I have not seen the variable allDay being set to anything other than false. A variable declared globally never becomes unset. Variables that are local to a function are destroyed as soon as the function ends.
  15. Is this a Javascript assignment or a jQuery assignment? You probably shouldn't be mixing them both, especially if you're still learning. You need to start with the basics. To begin with, do you know how to set the src property of an image element? It's just one line of code. You can't move on until you're able to do that.
  16. Where did you get the idea to use addEvent() in the first place? Wherever you got it, they would have taught you how to create it. Another problem is that in your rollover function you're not setting the variable img1. You need a line var img1 = something in order to declare the variable. This looks like homework, check through your notes or other class resources to see how the changeBatman() function should be made.
  17. Have you defined the addEvent() and changeBatman() functions? You seem to be using both Javascript and jQuery. Just choose one of them. If you're using jQuery, be sure you've included the jQuery library into your page.
  18. That error message is saying that there's no property redemptionLocations inside data This documentation does not seem to have information about the structure of the response, so I had to go searching through the response myself. The response does contain a redeptionLocations property and it has at least one item in it. Maybe data does not have the value you expected it to. Check the value of data using console.log(data) and seeing what shows up in the console.
  19. What happens when you try it? "Doesn't work" can mean a variety of things, check your browser's Javascript console and see what messages show up. Perhaps the redemptionLocations array is empty, in which case there's no element [0] to access. Can you point me to the documentation for this web service? Another thing to note is that arrays can have zero or more values, and the index starts at zero. To look at all the elements of an array you need a loop. Scroll down to "Looping Array Elements" in this page: http://www.w3schools.com/js/js_arrays.asp
  20. If you're serious about your website you should use a server-side language. Almost all web hosts these days have PHP installed with no extra cost, so since it's there you might as well use it. PHP is excellent for repeating content across many pages. iframes are the only pure HTML way to do it. Why are you opposed to jQuery? jQuery could at least provide a much smoother experience than iframes. You have jQuery and probably PHP at your disposal but refuse to use them. I can't understand why.
  21. You can add the onclick attribute to any element. Even to an <a> element. just be sure to return false; at the end to prevent the link from going somewhere. <a href="#" onclick="document.getElementById('mySound').play(); return false;">
  22. If you want to open a modal box you have to assign an event handler to the link which calls the modal('open') method on the box. $(".delete-row").click(function(e) { $("#myModal").modal('open'); e.preventDefault(); // Prevent the link from opening a new page}) Remember that if you want to add a class "delete-row" to your link, you have to add it inside the same class attribute that has the glyphicon and other classes. You can't have two class attributes. class='one glyphicon glyphicon-trash delete-row'
  23. It doesn't look like bootstrap was prepared for that. What you can do is use the jQuery function for the tooltop. Give your link a class or ID and call the tooltip() method. $("#delete-row").tooltip(); I suspect you're creating multiple rows and you're giving the same ID "delete-row" to all the links. This isn't going to work, an ID can only appear once on the page. If you want more than one use a class instead.
×
×
  • Create New...