Show div on Submit

I want to use a script that allows a div (with a class = " result ) to be shown when input type =" submit "id =" calc "is clicked .

Here's the codes:

Google API and script

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

<script>
$(document).ready(function(){
    $("#calc").click(function(){
        $("result").show();
    });
});
</script>

      

Input type = "submit"

<input id="calc" type="submit" name="submit" value="Submit">

      

Div with class = "result"

<div class="result" align="center">
<form>
<textarea readonly="readonly" class="area" rows="6" cols="100" onclick="this.focus();this.select()"><?php
echo "<div style=\"width: 700px; padding: 10px; border: 5px groove #DD670F\"><p align=\"center\">[color=#DD670F][size=14]<strong>";
echo $title;
echo "</strong>[/size][/color]<br><br>";
echo "<img width=\"100%\" src=\"";
echo $img;
echo "\"></p>[color=#DD670F]<b>Titolo:</b>[/color] ";
echo "$title<br>";
echo "$seriesok $series $seriesbr";
echo "[color=#DD670F]<b>Autore:</b>[/color] ";
echo $autor;
echo "<br>[color=#DD670F]<b>Lingua:</b>[/color] ";
echo $language;
echo "<br>[color=#DD670F]<b>Tags:</b>[/color] ";
echo $tags;
echo "<br>[color=#DD670F]<b>Trama:</b>[/color] ";
echo $plot;
echo "<br><br>[color=#DD670F]<b>Image Preview:</b>[/color]<br>";
echo "[SPOILER]";
echo $imgpreview;
echo "[/SPOILER]<br>";
echo "[color=#DD670F]<b>Download Link:</b>[/color] [URL=";
echo $dllink;
echo "]<u>Download</u>[/URL]</div>";
?>
</textarea>
</form>
</div>

      

In CSS

.result {
  display: none;
}

      

Thank!

+3


source to share


4 answers


use below code

$(".result").show();

      

Use selector .

for class element



NOTE. If the input type is your button submit

then the page will be redirected to another page or the same page as the action set in the form tag

use input type like button

<input id="calc" type="button" name="submit" value="Submit">

      

+2


source


Since this is the class you are referring to, you must use .

before result

:



$("#calc").click(function(){
     $(".result").show();
});

      

0


source


$("#calc").on("click", function(e){
  e.preventDefault();
  $(".result").show();
});

      

0


source


Your solution to the problem replaces this line

$("result").show(); 

      

to

$(".result").show();

      

0


source







All Articles