Kuv pub ib cov qhov Web site ntawm ib tug neeg laus vendor thiab yuav ua tau ib qho teeb meem loj, me duab. Cov dluab yuav tsum muaj 60×50 tab sis vim khib, tus thawj vendor yuam lawv ua 42×42, li ntawd, lawv nrhiav squashed:
Cov duab zoo |
Teeb duab |
Ntawm no yog cov markup (dog dig yooj yim zog):
<table hoob = 'ncua-outlook'>
<thead>
<tr>
<th dav ='100′>3 Tuesday</th>
</tr>
</thead><tbody>
<cov chav kawm tr = 'huab cua'>
<Td dav ='100′>
<ul>
<lis hoob = 'high'>Siab: 72°F</lis>
<lis hoob = 'low'>Qes: 44°F</lis>
<lis hoob = 'mob'>Tshav ntuj
<img src =’http://deskwx.weatherbug.com/images/Forecast/icons/localized/60×50/en/Trans/cond007.png’ dav ='42’ qhov siab ='42’ xwm =” />
</lis>
</ul>
</Td>
</tr></tbody>
</cov lus>
Koj mam li nco tias txawm ho lub kev ua kom cov duab xwb qhia qhov kom zoo dimension (60×50) tus thawj vendor yuam nws hauv 42×42. Ua li cas? Vwm.
Xijpeem, Kuv xav tau txoj kev sai thiab yooj yim tov rau no qhov teeb meem thiab kuv muab rau jQuery. Qhov ua kom yuam kev los nrhiav tau txhua yam txog qhov tsim nyog tau <img> cim npe. Kuv tsis xav muck cov cim kev lwm img npe (cov uas muaj ntau ntau). JQuery no me ntsis puas tau qhov ua kom yuam kev:
<Script yam = "ntawv nyeem/javascript" src ="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></tsab ntawv>
<Script yam = "ntawv nyeem/javascript">
$(daim ntawv).npaj txhij(muaj nuj nqi () {$(' li.condition > img').txhua(muaj nuj nqi (Performance Index, yam khoom)
{
$(yam khoom).CSS("dav", "60");
$(yam khoom).CSS(qhov "siab", "50");
});
}); // nyob rau daim ntawv load
</tsab ntawv>
Chaws ntawd me ntsis pom qhov sau los ua <lis> cim npe cov hoob kawm uas nws yog "mob" thiab <img> cov me nyuam. Nws mam li iterates los ntawm tag nrho cov neeg ntawd. Ua haujlwm zoo li ib lub nplhaib.
Kuv yuav zaum khiav nws, tab sis kuv yeej tsis muaj ib hom txiv leej tub unix tias solved π mus 18 xaus-npawb tsab precision sed thiab cov awk thiab kuv tsis ntawd seb yog jQuery guy tog twg los .
</kawg>
Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin