0
Save list! I need a help here, I have a file ". html" where I assemble a list that is configured like this:
<!-- ... -->
<header>
function Open(id) {
console.log(id);
var x = $("#div"+id);
$.get("descrs/greanerydescriptions_pt.html #div_"+id, function(data) {
$("#content").append(data);
});
$("#headercontainer").hide();
return false;
}
</header>
<body>
<div class="container content" id="content">
</div>
<div class="container headercontent" id="headercontainer">
<div class="card cardheader" id="_000">
<img class="card-img-top cardimgheader" src="images/abobora.jpg" alt="Abóbora" id="imgh_000">
<header id="hdh_000"><h2 class="title">Abóbora</h2></header>
<div class="card-body" id="div_abobora">
<p>Nome Popular - Abóbora</p>
<p>Nome Científico - Cucurbita moschata Duch.</p>
<div class="form-group" align="right">
<a href="descrs/greanerydescriptions_pt.html#div_000" class="btn btn-primary" id="btnh_000" onclick="Open('_000')" target="_parent">Descrição e Plantio</a>
</div>
</div>
</div>
<br>
<div class="card cardheader" id="_001">
<img class="card-img-top cardimgheader" src="images/abobrinha.jpg" alt="Abobrinha" id="imgh_001">
<header id="hdh_001"><h2 class="title">Abobrinha</h2></header>
<div class="card-body" id="div_abobrinha">
<p>Nome Popular - Abobrinha italiana, abobrinha verde, abobrinha</p
<p>Nome Científico - Cucurbita pepo L.</p>
<div class="form-group" align="right">
<a href="descrs/greanerydescriptions_pt.html#div_001" class="btn btn-primary" id="btnh_001" onclick="Open('_001')" target="_parent">Descrição e Plantio</a>
</div>
</div>
</div>
<br>
</div>
<!-- ... -->
</body>
The file "greanerydescriptions_pt.html" is configured like this:
<!-- ... -->
</header>
<body>
<div class="card cardcontainer" id="div_000">
<img class="card-img-top cardimgcontainer" src="../images/abobora.jpg" alt="Abóbora" id="imgc_000">
<header id="hdc_000"><h2 class="title">Abóbora</h2></header>
<div class="card-body" id="div_abobora">
<p>Nome Popular - Abóbora</p>
<p>Nome Científico - Cucurbita moschata Duch.</p>
<!-- ... -->
</div>
</div>
<br>
<!-- ... -->
<div class="card cardcontainer" id="div_001">
<img class="card-img-top cardimgcontainer" src="../images/abobrinha.jpg" alt="Abobrinha" id="imgc_001">
<header id="hdc_001"><h2 class="title">Abobrinha</h2></header>
<div class="card-body" id="div_abobrinha">
<p>Nome Popular - Abobrinha italiana, abobrinha verde, abobrinha</p>
<!-- ... -->
</div>
</div>
</body>
The code of the function Open(id) {...}
ta working, but it brings the entire file, and I need it to bring only the div specifies that this instantiated in the event `onclik="Open('_xxx');".
I don’t know how to fix this.
Could someone help me?
Thanks
tried to use load jQuery?
– LeAndrade
Pow, @Leandrade, da no mesmo
– Armando Marques Sobrinho
I wonder if it’s the same??
– LeAndrade
already tested here, in the second file, only have the Divs, as I put in the question, but both with the load as with the get Bringing the page with all the Divs. I will change once more to see, I tell you if confirmed
– Armando Marques Sobrinho
so did I:
$("#content").load("descrs/greanerydescriptions_pt.html #div_"+id);
brings all the M*das of the Divs you have in the file, carai, Jah to getting the roids fingers to test this drug– Armando Marques Sobrinho
But you know which div it is to bring?
– LeAndrade
The function
load
will load the document, if what you want is just the specific id you will have to do it next to the server, since you will have to work on the file to then recover only the necessary.– NoobSaibot
He wants to carry a div, in case with the load jQuery to do so for example (load"page.html #umaDiv") only the div is loaded a iv and not the whole document. I just didn’t understand the #div +id that he wants to pass in the load function.
– LeAndrade
He wants to recover only
#div_"+id
that is in the document to be loaded. As far as I know this will not be possible without handling the contents before.– NoobSaibot
Eh that same @Noobsaibot, eh exactly like this written in the event call, ie: in
onclick="Open('_000');"
I call Function, dai,...load("blábláblá.html #div_" + id)
, where "id" is the parameter passed in the call. You could answer right here as I would have to treat the "content before"?– Armando Marques Sobrinho
o **#div_" + id @Leandrade, in this case, would be
...load("blablabla.html #div_000")...
when I click on the <a> tag that calls the event with...('_000'), ou ficaria:
..(load".... html #div_001")quando eu clicar no <a> com
...('_001') and so on– Armando Marques Sobrinho