Jump to content

Ingolme

Moderator
  • Posts

    14,894
  • Joined

  • Last visited

  • Days Won

    176

Posts posted by Ingolme

  1. You probably would have to do the math yourself for each pixel and draw the result on a canvas. I don't think that would run fast enough to work on videos. There is nothing natively in Javascript or HTML that converts between RGB and HSL colors that I am aware of.

    To run algorithms on individual pixels, I would use getImageData() and putImageData() to do pixel manipulation.

  2. backgroundColor needs a capitalized C.

    IDs are not permitted to begin with a number, but I think browsers might still work if you do that. I would recommend fixing the ID anyway.

  3. 2 hours ago, dsonesuk said:

    You have all the information required from element itself, without the need of inline event attribute. You just need to know how to gain that information.

    
    
    
                                          // Hungarian notation style
                                          const
                                          cTabButtons = document.querySelectorAll('.tablinks');
    
                                          cTabButtons.forEach(tabButton => tabButton.addEventListener("click", function() {
                                          openCity(event, this.textContent);
                                          }));

     

    As shown in this post, there isn't a good reason to use HTML attributes for events and they severely hinder code maintainability.

    In this scenario though, the global event variable wouldn't be needed since addEventListener passes it into the callback. I'd rewrite it like this:

    cTabButtons.forEach(tabButton => tabButton.addEventListener("click", function(e) {
      openCity(e, this.textContent);
    }));

     

  4. Your Javascript won't work because you're calling openCity() and assigning the return value of the function as the event handler, it seems you have little experience with using event listeners outside of HTML. Aside from that, using properties such as "onclick" for events is also a bad practice since it will overwrite any existing event listener on the element and can be overridden by other code written in the same way. This is why addEventListener() should be used to attach events.

    If you're going to use HTML attributes for event listeners, the only way to access information about the event is through the "event" variable, which is passed into the attribute along with "this". All browsers support it and have to continue supporting it as along as HTML attributes are being used for events.

  5. You should check the browser's Javascript console for errors. Most browsers let you see the console by pressing F12 on your keyboard. This will help you fix problems in the future.

    Right now, the error console would tell you that getElementsByID does not exist. The name of the method is getElementById. The "d" is lowercase and "Element" is not plural.

  6. Since the major email clients do not support video, I imagine MailChimp is removing the code for it. I'm pretty sure audio will not work either.

    Mail clients are extremely primitive, they support text and images and little else. Even layout and styling options are limited.

  7. If you assign a jQuery result to a variable, you do not need the $() function to use it.

    This should work, though I haven't tested it so there might be a mistake somewhere.

    ( function( $ ) {
    
        var modal = $('#myModal');
        var img = $('.myImg');
        var modalImg = $('#img01');
        var captionText = $("#caption");
    
        img.click(function(){
          modal.show();
          modalImg.attr("src", $(this).attr("src"));
          captionText.html($(this).attr("alt"));
        });
    
    	var span = $(".close").first();
        span.click(function(){
          modal.hide();
        });
    
    } ( jQuery ) );

    I do not see any good reason to convert Javascript to jQuery. jQuery is far less efficient and isn't natively built into browsers, requiring a download of an external file before it can run.

    • Like 1
  8. The second condition only gets tested if the first one was false. Since 5 is actually greater than 2, it does not need to go on and test the second condition.

    If you want both conditions to be tested, you do not need the elif() statement. A second if() will do the job.

  9. Looking at the picture, my guess is that you should actually set it to "span 6" if you want each box to be half the width of the grid.

    If you are already using an ID selector in CSS on these elements, you will not be able to override it with a general selector like "body footer". ID selectors cannot be overridden except by other, more specific ID selectors.

  10. You will have to loop through the second array for each element in the first array to compare their values.

    
    $found = false;
    foreach($_POST['services'] as $id) {
      foreach($serviceslist as $service) {
        if($service['serviceID'] == $id) {
          $found = true;
          break;
        }
      }
      if($found) break;
    }
    
    if(!$found) {
      echo json_encode('nosuchservice');
    }

     

  11. Unfortunately, the website staff do not interact on the forums. You might be able to contact them at help@w3schools.com

    It looks like the material of the courses is the same as the related tutorials on the website. It says this on the HTML course page: https://courses.w3schools.com/courses/html

    Quote

    This is a structured and interactive version of the w3schools HTML Tutorial together with the w3schools certification. 

     

    The General forum is OK for questions that don't have a particular forum for the category.

×
×
  • Create New...