Display an element exclusively for mobile users

I am trying to display a text element only when a link is clicked in the mobile view. I suspect there might be a syntax error in this code, but I can't pinpoint where it is.

$("#Link1").click( function()
{
if($(window).width() > 800 )
  {
   $("#Text1").show();
  }
});

Answer №1

It's not a syntax mistake, but rather a logical flaw! You should consider replacing the character > with <:

$("#Link1").click( function() {
  if($(window).width() < 800 ) {
   $("#Text1").show();
  }
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the reason that when we assign `'initial'` as the value for `display` property, it does not function as intended for list elements?

To toggle the visibility of elements, I have created a unique function that accepts an object and a boolean. Depending on the boolean value, either 'none' or 'initial' is assigned to the 'display' property of the specified obj ...

Creating a responsive Google map within a div element: A step-by-step guide

I am experiencing difficulties with implementing a responsive Google map on my webpage. To achieve a mobile-first and responsive design, I am utilizing Google Map API v3 along with Bootstrap 3 CSS. My objective is to obtain user addresses either through th ...

Adjust mouse coordinates to be relative to the coordinates of the <canvas> element

I'm currently facing the challenge of determining the exact location of the mouse on a canvas grid while still maintaining resizability. As of now, I have the mouse coordinates based on its position on the screen (x and y). The issue arises from the ...

Tips for displaying a loading message during an AJAX request?

My AJAX function is set up like this: function update_session(val) { var session_id_to_change=document.getElementById('select_path').value; $.ajax({ type: "GET", url: "/modify_path/", asy ...

Perform a jQuery function and SQL query when a selection is made in a dropdown menu

Struggling to execute a SQL query on drop-down menu selection. Here's my current code: <script> $('#templateid').change(function(DoUpdateOnSelect) { $.post('page.edit.php?page_id=(-->Need help in retrieving this id from the pa ...

Start CSS3 Animation Automatically

I am working on a multi-page website with a slider that includes a CSS3 animation featuring the famous rocket animation. Here is the code snippet I used: #outerspace { position: relative; height: 400px; background: #fff; color: #fff; } di ...

Aligning text to the center and having it displayed on either side of it

Hey there, I need help with the following: <div id='1'></div> <div id='2'></div> <div id='3'></div> I want to place a single word into each div. The width of each div should be ...

Determining the Sum of Values in a Specified Row

Currently, I am in the process of creating a system that requires: A table with multiple rows, one of which is labeled Total I need a script that can sum up all the values in the Total column Furthermore, I want to include the session user so that it onl ...

complete collection of sass and scss website templates

Are there any comprehensive sass/scss templates or mixins similar to what you get with compass, but designed for an entire website? For example, can you define 2 columns, width, color, etc. and have it generate a full site/template? Thanks, Rick ...

The gauge created dynamically using the justgage plugin does not display the value

I am currently experimenting with dynamically adding gauges, and although they are displayed on the screen, the values being shown are incorrect. Even when the graph indicates a different value, it still displays 0. These gauges are triggered by an onclick ...

Issue with displaying Vue.js page within iframe in Firefox

We are facing an issue where a Vue.js page with an Echarts pie chart is not displaying in Firefox, even though it shows up perfectly in Chrome and IE. Replacing the Echarts page with basic numbers did not solve the problem in Firefox. Here is how i ...

Troubleshooting problem with Chrome caused by Ajax-loaded content

When I dynamically load content using the code below, I encounter an issue. $(document).ready(function() { $("#tags").keyup(function(){ var q = $(this).val(); $.ajax({ ...

I am unable to retrieve the value from the database after modifying the field to make a selection

I'm trying to create a select option form but I'm having trouble retrieving the current value when editing. <select name="t_proyek_kd_proyek" id="t_proyek_kd_proyek" class="select-search" value="<?php echo $nm_proyek; ?>" placeholder="P ...

What is the best way to center my image both vertically and horizontally?

Utilizing react.js to develop a template website has been my current project. The issue arose when I began constructing the first component of the site. The dilemma: The picture was not centered on the page, neither vertically nor horizontally. Despite ...

Ways to extract the ID by iterating through buttons

I encountered a message in my browser while looping through buttons with onclick function(). Are there any alternative solutions? Error handling response: TypeError: self.processResponse is not a function at chrome-extension://cmkdbmfndkfgebldhnkbfhlneefd ...

Is it possible to make side elements expand to occupy the remaining screen space beyond the container?

This is what it's supposed to look like: The goal here is to have the red element on the left expand to fill the remaining space beside its content, as well as the grey on the right. I am utilizing bootstrap which means the center elements occupy 117 ...

Problems with JQuery Ajax Json Response

Provided Form Section: <script type="text/javascript" src="js/aboneol.js"></script> <h4>Subscribe</h4> <div class="newsletter"> <span id="aboneolerror">< ...

Add a picture to a particular CLASS within a DIV

Using the tampermonkey code provided below, I have successfully managed to create a new div and attach it to a specific class. I have also been able to display some text, but my goal is to incorporate an image and possibly a script in the future. I would ...

CSS inset box-shadow creates a gap between collapsed borders

I need help with a strange issue I'm facing. I have a table where border-collapse is set to collapse, and there's an unusual gap between the box-shadow inset and the border. The size of this gap increases as the border width gets larger. How can ...

What is the most effective way to address duplicate title/meta tags on paginated pages? Can you share some recommended strategies for handling this

Google's webmaster tools are indicating the presence of Duplicate title tags on pages that have pagination. Below are a few examples: HTML suggestions Duplicate title tags Your title provides users and search engines with valuable information about ...